in reply to $@ alternative

Why is he using $@? If he's not using it for an eval error, can't he use something else?

Replies are listed 'Best First'.
Re^2: $@ alternative
by Gangabass (Vicar) on Sep 10, 2007 at 06:35 UTC

    I don't know :-(. And he did't answer. Can i add

    { local $@; ...my code goes here... }

    to preserve $@?

      $@ 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