Exposing my ignorance, wanting help with use!

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Wed Feb 14 15:13:30 GMT 2007


On Wed, 2007-02-14 at 15:43 +0100, Rafael Garcia-Suarez wrote:
> On 14/02/07, Peter Hickman <peter.hickman at semantico.com> wrote:
> > The problem is the require in the eval. When it is called with class set
> > to, say, Stupid::Dispatcher::XSQL I get the following error:
> >
> > Error loading dispatcher 'Stupid::Dispatcher::XSQL': Can't locate
> > Stupid::Dispatcher::XSQL in @INC (@INC contains: /sw/lib/perl5
> 
> require takes a file name, not a module name. (excepted if followed by
> a bareword. see perldoc -f require for details.)

But UNIVERSAL::require gives you a universal ->require() method that
works on strings, so you can do it like this:

eval {
    $class->require() or die $@;
    $self->{dispatcher}->add_dispatcher( $handler, $class->new($config) );
};

Or you could use eval STRING to make it a barweword.

-- 
ilmari



More information about the london.pm mailing list