Gunnar Hjalmarsson <no*****@gunnar.cc> wrote in message news:<bs********************@newsb.telia.net>...
Patrick LeBoutillier wrote: Is there anyway to be notified when the use/require of a module
fails?
Basically I would like to setup a sub that gets called whenever a
use/require call doesn't find what it is looking for. Sort of an
AUTOLOAD but for use/require.
Any ideas?
eval "use Some::Module";
mysub() if $@;
That's good, but I would like this to happen transparently behind the scenes, i.e.:
BEGIN {
# Hook up the sub "no_such_module" to be called when use/require
# fails
}
use IO::File ; # nothing happens
use File::Find ; # nothing happens
use Absent::Module # "no_such_module" called with arg "Absent::Module" ;
sub no_such_module {
my $module = shift ;
warn("Module $module not found.") ;
}