Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: why use a coderef?

by ferreira (Chaplain)
on Jun 25, 2007 at 20:25 UTC ( #623246=note: print w/replies, xml ) Need Help??


in reply to why use a coderef?

There are some subtle differences:

  1. Unless the declaration of some_subroutine was moved up, there would be a warning about an undefined subroutine. The assignment runs after the declaration (which happens on compile-time) and so no warning.
  2. if the code were using anonymous subroutines as in
    my $coderef = sub { #...do something with @_... return ($value1, $value2); };
    there would be no entry on the current package/namespace/stash. That makes a really private code.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-10-21 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (217 votes). Check out past polls.

    Notices?