At 10:55 AM 8/30/01 +0200, Edwin Günthner wrote:
>Hi there,
>
>In BASIC you have "on error goto", in REXX you
>can write "SIGNAL ON ERROR".
>I am wondering if there is a similiar feature in Perl ...

There are various features and modules that can combine to give you this 
capability (and a lot more).

For throwing and catching exceptions (which is a better paradigm than "on 
error goto" IMHO), use die and the block form of eval.  Or use Error.pm, 
which wraps them in a nice try/catch syntax.

For catching warnings or dies, use a handler in $SIG{__WARN__} or 
$SIG{__DIE__}.

To make failed system calls throw exceptions instead of returning false, 
use Fatal.pm.

The exception model is the one you want to look into.  Read a chapter about 
it in a Java book if you don't know what it is.  Then do 'perldoc -f eval' 
and 'perldoc -f die' to see how it's done in Perl.  It's also covered in 
pages 154-159 of my book (URL below).


--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to