Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://386997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found