1

我是 Perl 的新手,我正在通过执行以下操作在 Windows 7 的 CommandPrompt 对话框中执行 .pl 文件:

c:\perlscripts\runReport.pl 5 

除了在 CommandPrompt 对话框中查看输出之外,还有一种方法可以将输出重定向到文本文件吗?

任何帮助/方向将不胜感激。问候。

4

2 回答 2

4

如果您将“> filename.txt”附加到您的行,它会将结果输出到文件中。如果你想两者都做,显然在http://code.google.com/p/wintee/上有 wintee 实用程序。如果它类似于 UNIX tee,那么使用它应该只需要附加 '| tee filename.txt' 到您的行。

于 2013-01-10T17:24:06.850 回答
0

而不是在命令行中打印输出。您可以将输出写入文件。

# Opening file to write the program's output. 
open(FH, ">myFile.txt") or die "Cannot open myFile.txt";

# include module to dump output.
use Data::Dumper;
print FH Dumper(@output);

close FH;

否则你可以这样写:

perl my_script.pl > myFile.txt
于 2013-01-10T18:24:20.980 回答