Perl将值写入文件,参考实例如下:
1、open( my $fh, '>', 'fruit.out' ) or die $!;
print $fh $_ for @output;
2、open (OUTFILE,">>./outfile");
print OUTFILE "$a";
close(OUTFILE);
数组写入如下:
#从头开始写
open(FILE,">fruit.txt");
#文件结尾追加
open(FILE,">>fruit.txt");
print FILE "@arr";
open (OUTFILE,">>./outfile");
print OUTFILE "$a";
close(OUTFILE);