Search code examples
perlstrictdata-dumper

Using Dumper not triggering a failure


when running code like this:

use strict;
print Dumper "something";

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.


Solution

  • One of the valid syntaxes for print is

    print FILEHANDLE LIST
    

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