Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: Help Changing use into require/import

by Discipulus (Abbot)
on Mar 07, 2018 at 22:03 UTC ( #1210485=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2021-03-07 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (123 votes). Check out past polls.

    Notices?