Sep 022010
Simple try catch block in Perl
Answer:
Perl don't have try/catch statement by default, but you can simulate using the following way:
eval {
print 1/0;
};
if ([email protected]) {
print "Error message: [email protected]";
};
When executed, it shows:
Error message: Illegal division by zero at test.pl line 7.