in reply to Re: Runtime instantiation decisions
in thread Runtime instantiation decisions

This is expensive and dangerous:
eval "require $class;"; # Note: "" *NOT* {} !
whereas this is cheaper and safer (no firing up of the compiler):
(my $file = $class) =~ s#/#::#g; require $file;
Please note that for future programs. (Yes, portabilty to macs and VMS is sacrificed.. for that, pull down File::Spec. But this works on Unix and Windows.)

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: Re: Runtime instantiation decisions
by LogicalChaos (Beadle) on Mar 30, 2002 at 19:01 UTC
    Don't you mean something like this instead?
    (my $file = $class) =~ s^::^/^g; require "$file.pm";
    Now, this seems to work using file spec:
    my $file = File::Spec->catfile( split /::/, $class ) . ".pm";
    Thanks for the time and tips,
    LogicalChaos