Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 wandering the Monastery: (4)
As of 2026-02-18 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.