Perl读写文件模板

Posted 自动化测试日记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Perl读写文件模板相关的知识,希望对你有一定的参考价值。

use strict;use warnings;my $Read_file="a.txt";my $Write_file="out.txt";open(RF,$Read_file) or die $!;open(WF,"+>$Write_file") or die $!;while(my $line=<RF>){ chomp($line); print WF "$line\n";}close(RF);close(WF);



use strict;use warnings;my $Read_file="a.txt";my $Write_file="out.txt";open(RF,$Read_file) or die $!;open(WF,">>$Write_file"or die $!;while(my $line=<RF>){ chomp($line); print WF "$line\n";}close(RF);close(WF);

功能:把已存在的a.txt文件复制一份输出到out.txt。其中一个为追加模式写文件。


以上是关于Perl读写文件模板的主要内容,如果未能解决你的问题,请参考以下文章