Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Let a module call a sub of the caller

by SuicideJunkie (Priest)
on Sep 06, 2012 at 19:11 UTC ( #992167=note: print w/ replies, xml ) Need Help??


in reply to Let a module call a sub of the caller

You can pass a reference to a sub, and let other code call that whenever you like...

use strict; use warnings; { my $subref = sub { print "Hey, Hey!\n"; }; Foo($subref); } exit 0; sub Foo { my $callback = shift; print "Foo started\n"; $callback->(); print "Foo is done\n"; }


Comment on Re: Let a module call a sub of the caller
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2014-12-22 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (126 votes), past polls