Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: To & or not to & ?

by Aighearach
on Nov 11, 2004 at 23:29 UTC ( #407222=note: print w/replies, xml ) Need Help??


in reply to Re: To & or not to & ?
in thread To & or not to & ?

Note that, & only passes @_ IF you leave off the parens.

So that, if bar was implemented

sub bar { &foo(); }
then it wouldn't pass anything at all to foo. So, &FUNC should be considered a different way to call than &FUNC(), because only one of them does something different than FUNC()

--
Snazzy tagline here

Replies are listed 'Best First'.
Re^3: To & or not to & ?
by !1 (Hermit) on Nov 12, 2004 at 00:58 UTC
    because only one of them does something different than FUNC()

    Actually, all of them do something different as shown below:

    > perl -le'@_=2;sub a($$) {shift or 1};print &a' 2 > perl -le'@_=2;sub a($$) {shift or 1};print &a()' 1 > perl -le'@_=2;sub a($$) {shift or 1};print a()' Not enough arguments for main::a at -e line 1, at end of line Execution of -e aborted due to compilation errors.

    Sorry for the pedantry.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2021-10-17 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (72 votes). Check out past polls.

    Notices?