in reply to Re: print (...) interpreted as function
in thread print (...) interpreted as function

$ perl -wle 'print (3) + 3 and exit if 1' print (...) interpreted as function at -e line 1. 3

Abigail

Replies are listed 'Best First'.
Re: print (...) interpreted as function
by jonadab (Parson) on Sep 09, 2003 at 13:15 UTC

    Ah, yes, of course. The warning exists in case some poor C programmer tries to do something like this:

    print ($x + $y) * $z || die "Unable to print, $!\n";

    This shouldn't be a problem for anyone who thinks in Perl, because Perl is nicely consistent: if it looks like a function call, Perl treats it like a function call. However, for fledglings who think in another language, especially a statement-oriented language, and try to translate into Perl, this can be a weird gotcha. Rather than taking the warning out, perhaps it would be better to have a way to suppress warnings like this that have to do more with Perl semantics than with what could be logic mistakes or typos in the program (such as a variable only used once).


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/