Take me over?
NAME
AnyLoader - Automagically loads modules for fully qualified functions
SYNOPSIS
use AnyLoader;
Carp::croak("This is going to hurt the Perl community more than it ".
"is going to hurt you!");
DESCRIPTION
AnyLoader will automagically load the module and import the function for any fully qualified function call. Essentially, this means you can just call functions without worrying about loading the module first.
In the example above, AnyLoader does the equivalent of "require Carp" before the call to Carp::carp(). This should be useful for the many cases where one does:
if($error) {
require Carp;
Carp::croak($error);
}
to avoid loading Carp at startup.
AnyLoader is package scoped.
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 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, no AnyLoader
will do so for the current package. no AnyLoader
also takes a list of modules. These modules are those which are specifically 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 (not lexical).
BUGS and CAVEATS
The effects should really be lexically scoped, but I don't think I can pull that off.
This module requires on the "Use of inherited AUTOLOAD for non-method" deprecated feature.
$SIG{__WARN__} had to be used to suppress a warning about the deprecated feature.
Defines UNIVERSAL::AUTOLOAD which may interfere with other modules.
Despite what you'd think, AnyLoader *will* work with modules which employ an autoloader.
AUTHORS
Arnar M. Hrafnkelsson <addi@umich.edu> and Michael G Schwern <schwern@pobox.com>
LICENSE
Copyright (c) 2000 Arnar M. Hrafnkelsson and Michael G Schwern. All Rights Reserved.
You may distribute under the same license as Perl itself.