File::Util make_dir 不需要的输出

发布于 2024-10-05 20:37:19 字数 1228 浏览 2 评论 0原文

使用此子时,如果我传递一个包含错误字符的目录,它会将其输出发送到控制台,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

居里长安 2024-10-12 20:37:19

使用 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.

花之痕靓丽 2024-10-12 20:37:19

“仅抑制输出”可能可以通过 eval/die 构造来完成。像这样:

eval { make_dir (...) };
if ($@) { die "nice short error message" };

然而,那长长的错误消息仍然让我震惊。这太侮辱人了,我把它误认为是 Windows CLI 实用程序输出,如您所见:)

"Just suppressing the output" probably can be done through eval/die construct. Like this:

eval { make_dir (...) };
if ($@) { die "nice short error message" };

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文