Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Anonymous Subroutines

by dsb (Chaplain)
on Jul 30, 2004 at 13:50 UTC ( #378686=note: print w/ replies, xml ) Need Help??


in reply to Anonymous Subroutines

An anonymous subroutine is a reference to a subroutine. For lots of infor: perlref.

For the quick rundown:
Sub routines can be referenced, and then later dereferenced for access. Useful if you need to create an option handler or something:

$opt = "opt" . $ARGV[0]; $subhash = { opt1 => sub { print "This is option one"; }, opt2 => sub { print "This is options two"; } }; # indicate a function when dereferencing with & &{$subhash->{$opt}};


dsb
This @ISA my cool %SIG


Comment on Re: Anonymous Subroutines
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2015-07-30 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls