If you'd like try/catch semantics, they are implemented in Error.pm. Of
course you could do it yourself too:

sub try (&$) {
        my($try, $catch) = @_;
        eval { &$try };
        if ($@) {
                local $_ = $@;
                &$catch;
        }
}
sub catch (&) { shift };

# example
try {
        $dummy = $] / ($] - $]);
        print "\$dummy = $dummy\n";
}
catch {
        /division by zero/ and print "Caught:\n\t$_\n";
}

__END__

-- 
Mark Thomas                    [EMAIL PROTECTED]
Sr. Internet Architect         User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 


> -----Original Message-----
> From: Lee Goddard [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 28, 2001 7:25 AM
> To: Perl Users
> Subject: Exception handling in Perl
> 
> 
> Just found a need for exception handling on a big
> live project with an potentially nasty PM. Does anyone
> have any experience of the Exception modules?  Any good?
> Bad?  Better ideas?
> 
> Your input would be much appreciated....!
> 
> tia
> lee
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to