Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: pls help me to implement try-catch-throws without using any exception handling

by DamnDirtyApe (Curate)
on Aug 30, 2004 at 19:07 UTC ( #386997=note: print w/replies, xml ) Need Help??


in reply to pls help me to implement try-catch-throws without using any exception handling

Put the "try" code inside an eval block, then check the value of $@. Example:

#! /usr/bin/perl -w use strict; for my $i ( 2, 1, 0 ) { for my $j ( 2, 1 ) { eval { print "$j / $i = " . $j / $i . $/; }; if ( $@ ) { warn "Warning: $@"; } } } __END__

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://386997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2020-05-26 13:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?