perl逐行读取文件 如何把perl的输出结果保存到一个txt文件中?

如何把perl的输出结果保存到一个txt文件中?你可以有两个方案1) 用 dos 本身的功能perl yourscript.pl > C:result.txt2) 在 perl 里做open F,

如何把perl的输出结果保存到一个txt文件中?

你可以有两个方案1) 用 dos 本身的功能perl yourscript.pl > C:result.txt2) 在 perl 里做open F, ">C:/Result.txt" or die "$! Can"t prepare file!" opendir D "D:/read" or die "$! Can"t read dir!" print F "$_$/" while ( readdir D ) # 或者照你原来的写法就行了. closedir Dclose F