Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: localizing handles with anonymous subroutines

by particle (Vicar)
on Jun 10, 2002 at 16:13 UTC ( [id://173209]=note: print w/replies, xml ) Need Help??


in reply to Re: localizing handles with anonymous subroutines
in thread localizing handles with anonymous subroutines

yes, there's a huge advantage. do is not a subroutine. it cannot take parameters. just try to do this!

my %dispatch = ( sub_get_files => sub{ # takes one arg local *DH; opendir( DH, $_[0] ) or die 'Cannot open ' . $_[0]; return grep { -f $_ } readdir(DH) }, ); my @files = $dispatch{sub_get_files}->( $dir );
do executes immediately, and would spit the results into the hash. icky.<p

~Particle *accelerates*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-20 00:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found