如何将标准输出重定向到Perl中的文件? [英] How can I redirect standard output to a file in Perl?
本文介绍了如何将标准输出重定向到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...
这篇关于如何将标准输出重定向到Perl中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文