Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: What is the point of the & sigil for function refs?

by ihb (Deacon)
on Feb 11, 2005 at 14:20 UTC ( #430108=note: print w/ replies, xml ) Need Help??


in reply to Re: What is the point of the & sigil for function refs?
in thread What is the point of the & / ampersand sigil for function refs?

the local @_ is implicitly passed

It's even the same @_. This means that &foo(@_) and &foo; won't behave the same; see perlfaq7, "What's the difference between calling a function as &foo and foo()?". Demonstration:

use strict; sub foo { pop } sub bar { print "bar before: @_"; print '&foo : ' . &foo . " <--- I am a theif"; print "bar after : @_ <--- no c"; } sub baz { print "baz before: @_"; print '&foo(@_) : ' . &foo(@_); print "baz after : @_"; } bar(qw/ a b c /); print ''; baz(qw/ a b c /); __END__ bar before: a b c &foo : c <--- I am a theif bar after : a b <--- no c baz before: a b c &foo(@_) : c baz after : a b c

ihb

See perltoc if you don't know which perldoc to read!


Comment on Re^2: What is the point of the & sigil for function refs?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-08-01 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls