如何将标准输出重定向到Perl中的文件?
问题描述:
我正在寻找一个使用Perl将stdout重定向到文件的示例.我正在做一个相当简单的fork/exec工具,我想将孩子的输出重定向到文件而不是父母的stdout.
I'm looking for an example of redirecting stdout to a file using Perl. I'm doing a fairly straightforward fork/exec tool, and I want to redirect the child's output to a file instead of the parents stdout.
我应该使用等价的dup2()
吗?我似乎找不到它
Is there an equivilant of dup2()
I should use? I can't seem to find it
答
从perldoc -f打开:
From perldoc -f open:
open STDOUT, '>', "foo.out"
文档是您的朋友...
The docs are your friend...