in reply to checking from a module if a sub exists in main::
Export $delHook if you like. Then, in the main script:package Foo; use vars qw/$delHook/; $delHook = undef;
will set $delHook; in the module, when you need to call the sub:$Foo::delHook = \&somehook; # or just $delHook if exported
That way, rather than being restricted to calling a sub with a particular name, you call the subroutine by having a reference to it (which is what the \ does; the & is just to specify that it's the method and not something else). Note that the call will not occur if no delHook was set.$delHook->(any_arguments_here) if defined $delHook;
|
|---|