Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Think about Loose Coupling
 
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 wandering the Monastery: (6)
As of 2014-04-17 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (437 votes), past polls