Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: while loop

by mantadin (Beadle)
on Apr 26, 2006 at 10:12 UTC ( [id://545738]=note: print w/replies, xml ) Need Help??


in reply to Re^2: while loop
in thread while loop

Thanks for the info; I did not know that the &-form is considered a cargo-culted remnant.

OTOH, I am not aware of the &-form having any useful advantage. AFAIK, &f, if called from within another sub, is equivalent to f(@_) "but faster", as the camel books states (3rd edition, Chapter 6, scoping issues).

Replies are listed 'Best First'.
Re^4: while loop
by blazar (Canon) on Apr 26, 2006 at 10:23 UTC

    Well, perldoc perlsub explains it all. In brief, do not use the &-form unless you know what you're doing, i.e. either circumvent prototypes, if you're giving an explicit arg list or make current @_ visible to the sub, as you say.

      ... or when dereferencing a CODEREF or a symbolic reference to a subroutine name, or taking a reference to a subroutine, or when using the subroutine as an argument to goto ...

      /J\

        Indeed! And well done to point out - although we were talking about sub calls. However when dereferencing I'd recommend using (again: unless one knows what she's doing and has good reasons to!)

        $subref->(@args);

        This is not merely cosmetic: I actually met a situation in which a module using &$subref(@args) caused a bad interaction with some subs.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found