in reply to requiring perl modules
According to require, if the argument to require is not a bareword (if it's a variable as you have or an expression returning a name), Perl doesn't automatically add the .pm extension. I suspect you could get by with something like this:
use File::Spec; my $dir = 'modules'; my $mod = 'test'; my $module = File::Spec->catfile( $dir, $mod . '.pm' ); require $module;
The documentation also suggests this, which I don't like, though it is shorter:
eval "require $mod";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: requiring perl modules
by ysth (Canon) on Dec 03, 2003 at 19:28 UTC |