Perl将一个值写入文件

2024-11-16 04:26:15
推荐回答(2个)
回答(1):

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";

回答(2):

open (OUTFILE,">>./outfile");
print OUTFILE "$a";
close(OUTFILE);