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);
本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/1596188