Thursday, November 29, 2007

perl: special vars

$EVAL_ERROR
$@


The currently raised exception or the Perl syntax error message from the last eval operation. (Mnemonic: where was the syntax error "at"?)
Unlike $! ($OS_ERROR), which is set on failure but not cleared on success, $@ is guaranteed to be set (to a true value) if the last eval had a compilation error or run-time exception, and guaranteed to be cleared (to a false value) if no such problem occurred. Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting $SIG{__WARN__} as described later in this section. Note that the value of $@ may be an exception object rather than a string. If so, you can still probably treat it as a string if the exception object has stringification overloading defined for its class. If you propagate an exception by saying: die if $@; then an exception object will call $@->PROPAGATE to see what to do. (A string exception merely adds a "propagated at" line to the string.)



$!
$OS_ERROR
$ERRNO

If used in a numeric context, yields the current value of the errno variable, identifying the last system call error. If used in a string context, yields the corresponding system error string.



$@
$EVAL_ERROR

The Perl syntax error message from the last eval command.

No comments: