http://qs321.pair.com?node_id=638013


in reply to Re^2: $@ alternative
in thread $@ alternative

$@ is global, so yes you can localize it, (and in general you should make a local copy if you want to preserve a previous exception).

$@ being global, at the first exception triggered the previous contents of $@ will be destoyed, so that means probably your customer never used exception-eval blocks, or was just lucky, as the following code demonstrates.

% steph@ape (/home/stephan/r) % % perl -we '$@ = "customer stuff..."; eval { die "dont muck with $@!" +}; print $@' dont muck with ! at -e line 1. % steph@ape (/home/stephan/r) % % perl -we '$@ = "customer stuff..."; { local $@; eval { die "dont muc +k with $@!" }; } print $@' customer stuff...
cheers --stephan