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"; }
|
|---|