NAME
UNIVERSAL::require - require() modules from a variable
SYNOPSIS
# This only needs to be said once in your program.
require UNIVERSAL::require;
# Same as "require Some::Module;"
Some::Module->require;
# Ditto
my $module = 'Some::Module';
$module->require;
DESCRIPTION
If you've ever had to do this...
eval "require $module";
to get around the bareword caveats on require(), this module is for you. It creates a universal require() class method that will work with every Perl module. So instead of doing some arcane eval() work, you can do this:
$module->require;
And use Some::Module
can be done dynamically like so:
BEGIN {
$module->require;
$module->import;
}
It doesn't save you much typing, but it'll make alot more sense to someone who's not a ninth level Perl acolyte.
Methods
- require
-
$module->require; $module->require($version);
This works exactly like Perl's require, except without the bareword restriction. Since require() is placed in the UNIVERSAL namespace, it will work on any module. You just have to use UNIVERSAL::require somewhere in your code.
AUTHOR
Michael G Schwern <schwern@pobox.com>
SEE ALSO
UNIVERSAL::exports, "require" in perlfunc, http://dev.perl.org/rfc/253.pod