in reply to print (...) interpreted as function

IMO, the warning in question is unnecessary and should be removed if and only if it always occurs together with another warning such as useless use of foo in void context.

Does anyone know whether it's possible to trigger the 'interpreted as function' warning alone?


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

Replies are listed 'Best First'.
Re: print (...) interpreted as function
by Abigail-II (Bishop) on Sep 09, 2003 at 12:08 UTC
    $ perl -wle 'print (3) + 3 and exit if 1' print (...) interpreted as function at -e line 1. 3

    Abigail

      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$/