AnyLoader
view release on metacpan or search on metacpan
lib/AnyLoader.pm view on Meta::CPAN
AnyLoader is package scoped.
=head2 Restricting what gets loaded.
You might not want to let *every* package be AnyLoaded, so ways of
qualifying what gets loaded are provided. A list of modules can be
given to C<use AnyLoader> and only those modules will be AnyLoaded.
use AnyLoader qw(Data::Dumper Carp);
Data::Dumper::Dumper($foo); # This works.
LWP::Simple::get($url); # This doesn't.
If you wish to shut off AnyLoader, C<no AnyLoader> will do so for the
current package. C<no AnyLoader> also takes a list of modules. These
modules are those which are specifically B<not> to be loaded.
# AnyLoad anything but LWP and URI::URL.
no AnyLoader qw(LWP URI::URL);
The lists and effects are cumulative and package scoped (B<not lexical>).
t/AnyLoader-qualified.t view on Meta::CPAN
$ok = 0;
last;
}
}
return $ok;
}
# Change this to your # of ok() calls + 1
BEGIN { $Total_tests = 1 }
use AnyLoader qw(Data::Dumper);
eval { Text::Soundex::soundex('schwern') };
ok( $@ =~ /^Undefined subroutine &Text::Soundex::soundex called/ );
( run in 0.489 second using v1.01-cache-2.11-cpan-4d50c553e7e )