in reply to Issues with including via eval 'require'

I think you probably don't want the extra quotes. require "filename" means to require a filename, where require File::Name means to search @INC for a class (filename of File/Name.pm).

The usual reason behind the use of eval "require ..." is to make the contents of your variable into a bare word. The other reason, obviously, is to trap errors if the module is missing; or to execute the require at runtime instead of doing it before main execution.

You might also consider interpolation, so you don't have to explicitly concatenate like that.

eval "require $ARGV[0]"; die $@ if $@;

I have assumed that "foo::try" actually is in another file. If it's in the same file, your require is never going to work. :)

-Paul

Replies are listed 'Best First'.
Re^2: Issues with including via eval 'require'
by yaneurabeya (Novice) on Apr 26, 2007 at 18:45 UTC
    Ah, brilliant! That did the trick! Sometimes I get confused between "require ''" and "require", I think.. Thank you! PS foo::try was in another file :).
Re^2: Issues with including via eval 'require'
by Anonymous Monk on Apr 27, 2007 at 08:05 UTC
    require always happens at runtime.