1.文件读写与命令行参数
#!/usr/bin/perl
use strict;
if (@ARGV < 2){
die "USAGE: perl $0 inputfile outfile\n";
}
my ($infile) = @ARGV[0];
my ($outfile) = @ARGV[1];
open my $infile_fh,‘‘, "$infile" || die("Can‘t open the file!");
open my $outfile_fh, ‘>>‘, "$outfile"|| die("Can‘t open the file!");
while(<$infile_fh>){
#chomp;
print $outfile_fh $_;
}
close($outfile_fh);
close($infile_fh);
时间: 2024-10-12 07:54:10