File::Util make_dir 不需要的输出
使用此子时,如果我传递一个包含错误字符的目录,它会将其输出发送到控制台,如下所示:
PROCESS TERMINATED DUE TO ERRORS
File::Util can't use this string for �the name of a directory�.
�ddd??---?d�
It contains illegal characters.
Illegal characters are:
\ (backslash)
/ (forward slash)
: (colon)
| (pipe)
* (asterisk)
? (question mark)
" (double quote)
< (less than)
> (greater than)
\t (tab)
\ck (vertical tabulator)
\r (newline CR)
\n (newline LF)
Origin: This is a human error.
Solution: A human must remove the illegal characters from this string.
ARG _pak = File::Util
ARG purpose = the name of a directory
ARG string = ddd??---?d
1. File::Util::_throw
-called at line (1343) of blib/lib/File/Util.pm (autosplit into blib/lib/auto/File/Util/make_dir.al)
-was called with args
-was not called to evaluate anything
2. File::Util::make_dir
-called at line (35) of importdatafiles.pl
-was called with args
-was not called to evaluate anything
3. (eval)
-called at line (35) of importdatafiles.pl
-was called without args
-was not called to evaluate anything
如何抑制此输出(我只想打印“错误”而不需要所有这些详细信息)
when using this sub, if I pass a directory with bad characters it spits its output to the console like this:
PROCESS TERMINATED DUE TO ERRORS
File::Util can't use this string for �the name of a directory�.
�ddd??---?d�
It contains illegal characters.
Illegal characters are:
\ (backslash)
/ (forward slash)
: (colon)
| (pipe)
* (asterisk)
? (question mark)
" (double quote)
< (less than)
> (greater than)
\t (tab)
\ck (vertical tabulator)
\r (newline CR)
\n (newline LF)
Origin: This is a human error.
Solution: A human must remove the illegal characters from this string.
ARG _pak = File::Util
ARG purpose = the name of a directory
ARG string = ddd??---?d
1. File::Util::_throw
-called at line (1343) of blib/lib/File/Util.pm (autosplit into blib/lib/auto/File/Util/make_dir.al)
-was called with args
-was not called to evaluate anything
2. File::Util::make_dir
-called at line (35) of importdatafiles.pl
-was called with args
-was not called to evaluate anything
3. (eval)
-called at line (35) of importdatafiles.pl
-was called without args
-was not called to evaluate anything
How to suppress this output (I just want to print "Bad" without all this detailed info)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 File::Path qw/mkpath/?我不知道它是否可以在Windows下运行,但值得一试。
use File::Path qw/mkpath/? I don't know whether it runs under windows though, but it's worth a try.
“仅抑制输出”可能可以通过 eval/die 构造来完成。像这样:
然而,那长长的错误消息仍然让我震惊。这太侮辱人了,我把它误认为是 Windows CLI 实用程序输出,如您所见:)
"Just suppressing the output" probably can be done through eval/die construct. Like this:
However, that long error message is still stunning me. It was so insulting that I mistaken it for a Windows CLI utility output, as you can see :)