我在Perl中使用了一些系统命令。如何摆脱Perl中的STDERR
在下面的情况下,我得到的输出如下:
ls: import-log.*: No such file or directory
ls: error-log.*: No such file or directory
No specified files found for deletion
我的代码:
sub monthoryear()
{
@importlog = `ls -al import-log.*`;
@errorlog = `ls -al error-log.*`;
}
我不希望看到下面的输出,即使有没有文件。
ls: import-log.*: No such file or directory &
ls: error-log.*: No such file or directory
什么如果我想捕获该错误消息? – Sunny 2011-02-25 17:35:54
@Sunny - 在这种情况下,您可以使用文件而不是/ dev/null,只需替换为/ path/to /文件 – justkt 2011-02-25 17:37:02
我可以在变量中获取该文件吗? – Sunny 2011-02-25 17:38:02