我希望通过输入文件来更改 Perl 中的 txt 文件,然后在现有文件之间用空行导出它。我该怎么做呢?到目前为止我有这个:
#!/usr/bin/perl;
use strict;
use warnings;
print "Hi! This Program Will Input\n";
print "The File and Export A New\n";
print "File With A Blank Line In-Between\n";
print "Every Other Line\n";
sleep(2);
print "\n";
print "\n";
print "Working\n";
print "\n";
sleep(1);
print "\n";
print "Working\n";
sleep(1);
open(my $in, "<", "input.txt") or die "Can't Open Input.txt: $!";
open(my $out, ">", "output.txt") or die "Can't Open Output.txt: $!";
my @lines = <$in>;
while (<$in>) {
print $out
print $lines[$#lines];
print " ";
}
print "Completed Successfully!!\n";
print "\n";
print "Outputed to Output.txt\n";
close $in or die "$in: $!"
我错过了什么?我只是在学习 Perl,所以我不太了解。