如何将die函数的输出重定向到Perl中的文件?
发布时间:2020-12-15 21:49:44 所属栏目:大数据 来源:网络整理
导读:我想将die消息重定向到一个单独的文件,以便我可以稍后比较该文件以确定出错的地方. 但是这段代码给了我错误: $cat test.pluse strict;use warnings;my $log = "msglog.log";die $log "DEAD$!";$perl test.plMissing comma after first argument to die func
我想将die消息重定向到一个单独的文件,以便我可以稍后比较该文件以确定出错的地方.
但是这段代码给了我错误: $cat test.pl use strict; use warnings; my $log = "msglog.log"; die $log "DEAD$!"; $perl test.pl Missing comma after first argument to die function at test.pl line 5,near ""DEAD$!";" Execution of test.pl aborted due to compilation errors. $ 我不想做2>来自来电者.有没有办法从脚本中重定向它们? 解决方法
Perl的模具打印到STDERR,因此您可以将STDERR重定向到文件.
#!/usr/bin/env perl # the path above depends on your system open(STDERR,">>","errlog.log"); die "Hello"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |