in reply to Perl doesn't give error when module is not found

If a sub named Dumperrrrrrrrrr exists, then

print Dumperrrrrrrrrr $myvar;
means
print( Dumperrrrrrrrrr( $myvar ) );

But there is no sub named Dumperrrrrrrrrr, so

print Dumperrrrrrrrrr $myvar;
means
print( Dumperrrrrrrrrr $myvar ); # File handle and thing to print.

print tries to write to Dumperrrrrrrrrr, but no file handle is associated with that symbol, so it returns false.

You can use no feature qw( bareword_filehandles ); (5.34+) to detect these errors. use v5.38; (5.38+) also does the trick (plus more).

Replies are listed 'Best First'.
Re^2: No error from typo [was: Perl doesn't give error when module is not found]
by Jenda (Abbot) on Mar 27, 2024 at 17:20 UTC

    I don't think

    print( Dumperrrrrrrrrr $myvar );

    helps anyone to understand what's actually going on. While the situation is more complicated in case of print, the print Dumperrrrrrrrrr $myvar; is at least syntactically the Indirect Object Syntax. If the filehandle does exist, you can think of that statement as "calling the print() method of the Dumperrrrrrr object with the parameter $myvar".

    Jenda
    1984 was supposed to be a warning,
    not a manual!

      I don't think print( Dumperrrrrrrrrr $myvar ); helps anyone to understand what's actually going on.

      That's why I didn't write (just) print( Dumperrrrrrrrrr $myvar );.

      And no, it's not actually an indirect method call. Or any kind of method call. It's a function (i.e. a named operator) with a funky syntax.