
On 06/01/12 15:09, Chris Samuel wrote:
On 06/01/12 15:06, Russell Coker wrote:
When hacking some Perl code I encountered $@. It seems that is just a way of dumping the last error. Unfortunately Google doesn't help me because it only does a word based search.
man perlvar
$@ The Perl syntax error message from the last eval() operator. If $@ is the null string, the last eval() parsed and executed correctly (although the operations you invoked may have failed in the normal fashion). (Mnemonic: Where was the syntax error "at"?)
Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting $SIG{__WARN__} as described below.
Also see "Error Indicators".
We recommend people use Try::Tiny rather than eval and $@ these days, as there are several caveats for $@ that most people forget to take into account. use Try::Tiny; try { some(); more(); code(); } catch { say "An error! It was: $_"; } finally { say "Either way, we're done here.." };