in reply to Re: stronger than eval?
in thread stronger than eval?

with require, you'll have to handle import manually.

Replies are listed 'Best First'.
Re^3: stronger than eval?
by ikegami (Patriarch) on Sep 21, 2006 at 21:30 UTC

    I see that as a plus, since it probably doesn't make sense to import from something which is conditionally imported. However, it's not hard to import if so desired.

    BEGIN { eval { require Cache::File } or warn("Proceeding without Cache::File\n"); Cache::File->import(qw( ... )) if Cache::File->can("import"); }

    or

    BEGIN { my @imports = qw( ... ); eval "use Cache::File \@imports" or warn("Proceeding without Cache::File\n"); }

    The BEGIN ensures prototypes are properly loaded.