为什么我的脚本报告“eval“字符串”中未初始化的值”?

发布于 2024-07-09 00:23:04 字数 329 浏览 7 评论 0原文

我收到此警告:

Use of uninitialized value in eval \"string\" at myscript.pl line 57.

当我运行此代码时:

eval;
{
        `$client -f $confFile -i $inputFile -o $outputFile`;
};

if( $@ )
{
        # error handling here ...
}

是什么导致了错误?

如何解决根本原因? (或者以其他方式抑制警告?)

I am getting this warning:

Use of uninitialized value in eval \"string\" at myscript.pl line 57.

When I run this code:

eval;
{
        `$client -f $confFile -i $inputFile -o $outputFile`;
};

if( $@ )
{
        # error handling here ...
}

What is causing the error?

How can I fix the underlying cause? (Or otherwise suppress the warning?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

静若繁花 2024-07-16 00:23:04

无论如何,这里的 eval 绝对不会做任何事情。 反引号永远不会引发错误。 您要检查的不是 $@ 而是 $?

另外,如果您要丢弃结果,那么使用 system。 例如

system($client, '-f', $confFile, '-i', $inputFile, '-o', $outputFile) and do {
    #error handling here...
};

The eval here would do absolutely nothing anyway. Backticks never throw errors. It's not $@ but $? that you want to check.

Also, if you're throwing away the result, it may be a cleaner idea to use system. e.g.

system($client, '-f', $confFile, '-i', $inputFile, '-o', $outputFile) and do {
    #error handling here...
};
爱的故事 2024-07-16 00:23:04

eval 后面有一个分号。

There is a semicolon after eval.

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