http://www.perlmonks.org?node_id=1210485


in reply to Re^3: Help Changing use into require/import
in thread Help Changing use into require/import

> I wonder if "undef $@" before the eval would help ensure any error ending up in $@ is coming from the eval?

Better using local in such case (I think..)

{ local $@; eval "use Capture::Tiny qw(capture)"; if ( !$@ ) { $HAVE_Capture_Tiny = 1; } }

See also eval, DESTROY, die and $@ - educational couple of hours

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^5: Help Changing use into require/import
by stevieb (Canon) on Mar 07, 2018 at 22:08 UTC

    Yes, localizing $@ will get rid of at least one problem for certain, where $@ is quashed if it already has something from a previous eval.