in reply to false warning: print (...) interpreted as function

And if you use really AS function?
perl -Mstrict -wE "my $x = print ('string'); say ''; say $x" string 1 perl -Mstrict -wE "print('string')" string perl -Mstrict -wE "print ('string')" print (...) interpreted as function at -e line 1. string
No warning are issued in first and second examples.

L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: false warning: print (...) interpreted as function
by choroba (Cardinal) on Nov 06, 2015 at 12:55 UTC
    It depends on what you print, too:
    my $x = print ( (sort {$b <=> $a} grep defined, @_)[ 0 ], " - was a max defined value\n" );
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      According to the Camel Book (4th Edition, 2012, p. 918), parentheses around all the arguments should be ok, even with a space between the print and the opening left parenthesis:

      Also, remembering the if-it-looks-like-a-function-it-is-a-function rule, be careful not to follow the print keyword with a left parenthesis unless you want the corresponding right parenthesis to terminate the arguments to the print. Instead, interpose a + or put parens around all the arguments:
      print (1+2)*3, "\n"; # WRONG print +(1+2)*3, "\n"; # ok print ((1+2)*3, "\n"); # ok

      I’m guessing that the warnings pragma is made suspicious when the closing right parenthesis either (1) is followed by other expressions, or (2) doesn’t appear on the same line as the opening left parenthesis — as in the example cited.

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,