Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: why avoid & on function call

by kcott (Archbishop)
on Dec 27, 2020 at 19:14 UTC ( [id://11125810]=note: print w/replies, xml ) Need Help??


in reply to Re^2: why avoid & on function call
in thread why avoid & on function call

"The placement of a sub is important only when you call it without parentheses, ..."

I disagree with the inclusion of the word only in that statement. Here's a situation where placement is important when parentheses are used:

$ perl -wE ' sub meaning () { 42 } say meaning(); ' 42
$ perl -wE ' say meaning(); sub meaning () { 42 } ' main::meaning() called too early to check prototype at -e line 2. 42

You can, of course, predeclare and leave the definition for later:

$ perl -wE ' sub meaning (); say meaning(); # ... later in code with other subroutine defintions sub meaning () { 42 } ' 42

— Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2025-06-18 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.