Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: how to stop command

by haukex (Archbishop)
on Jul 23, 2018 at 17:39 UTC ( [id://1219121]=note: print w/replies, xml ) Need Help??


in reply to Re^2: how to stop command
in thread how to stop command

I don't think this particular eval is likely to suffer from the issues you mentioned.

True, in this case it's probably fine. But I think it's still a good habit to get into - even seemingly innocent pieces of code can trigger the problematic behavior:

eval { $foo = `some_bad_command` or die "blam" }; warn $@ if $@;

won't print anything if $foo happened to be an object with the problematic DESTROY on a problematic version of Perl.

The following doesn't print anything until Perl v5.26.0.

use strict; sub Foo::DESTROY { eval { 1 } } my $foo = bless {}, 'Foo'; eval { $foo = `some_bad_command` or die "blam" }; warn $@ if $@;

(Interestingly, according to a bisect, the commit that changed this behavior is a0833292cf, which has nothing to do with fixing $@ issues, so it appears to just be a side effect.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found