Perl中的输出流:STDERR,STDOUT,
发布时间:2020-12-15 23:20:48 所属栏目:大数据 来源:网络整理
导读:参见英文答案 Linux/Perl: Additional output buffers other than STDOUT and STDERR?????????????????????????????????????1个 我知道输出流STDOUT和STDERR.每当你打印到STDOUT时,在unix shell中你可以像这样重定向输出…… deviolog@home:~$perl test_scri
参见英文答案 >
Linux/Perl: Additional output buffers other than STDOUT and STDERR?????????????????????????????????????1个
我知道输出流STDOUT和STDERR.每当你打印到STDOUT时,在unix shell中你可以像这样重定向输出…… deviolog@home:~$perl test_script.pl > output.txt 要么 deviolog@home:~$perl test_script.pl 1> output.txt 当您打印到STDERR时,它看起来相同,但您切换到“频道”(?)编号2: deviolog@home:~$perl test_script.pl 2> output.txt 我可以在output.txt中找到我当时正在打印的错误输出. 我的问题是,我可以以某种方式访问??“频道”3号吗? print STDX "Hello World!n"; …允许重定向,如下所示? deviolog@home:~$perl test_script.pl 3> output.txt 附:一个子问题将是那些“渠道”^ _ ^的术语 解决方法
您可以使用open,append& =为模式创建一个打开文件描述符(fd)的Perl文件句柄,并使用文件描述符作为文件名.在您的情况下,您将使用以下内容:
open(my $fh,'>&=',3) 例如, $perl -E' open(my $fh,">&=",3) or die $!; say fileno($fh); say $fh "meow"; ' 3>output.txt 3 $cat output.txt meow (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |