使用Dumper不会触发故障 [英] Using Dumper not triggering a failure

查看:111
本文介绍了使用Dumper不会触发故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行这样的代码时:

use strict;
print Dumper "something";

什么都不会打印出来,并且在编译和运行时不会发生任何错误.为什么会这样?为什么strict不阻止此代码运行?为什么即使Dumper未知,运行时也没有错误?

nothing is printed out and no error occurs during compile and runtime. Why does this happen? Why doesn't strict prevent this code from running? Why is there no error at runtime, even though Dumper is unknown?

我知道在显式启用它们时会产生警告,但是我很感兴趣为什么将此代码以任何方式都视为正确".

I know it produces a warning when those are explicitly enabled, but I'm interested why is this code considered "correct" in any way.

推荐答案

print的有效语法之一是

print FILEHANDLE LIST

在您的程序中,Perl将Dumper视为文件句柄glob.

In your program Perl is treating Dumper as a filehandle glob.

在启用警告的情况下运行此代码将告诉您:

Running this code with warnings enabled will tell you:

print() on unopened filehandle Dumper at ...

这篇关于使用Dumper不会触发故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆