Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: false warning: print (...) interpreted as function

by Athanasius (Archbishop)
on Nov 06, 2015 at 13:17 UTC ( [id://1147095]=note: print w/replies, xml ) Need Help??


in reply to Re^2: false warning: print (...) interpreted as function
in thread false warning: print (...) interpreted as function

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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147095]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-19 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found