1 Dec 2006 01:07
Re: tiny improvements for perlmate.rb
Alex,
> The the reason we don't want to handle errors that were throw in eval
> blocks is the reason you mentioned. Typically, the user handles the
> error themself. But it is bad that $ <at> refers to exception_handler.pm
> line 34 after a die. I think we can fix this somehow.
>
Try the attached exception_handler.pm.
I only changed 'sub die'.
perl example:
__________
#!/usr/bin/perl
$a = 5;
$b = -1;
#open (F, '/t/t') || die "Can't find file and program exits!";
eval {
$c = $a / $b;
die "Denominator cannot be negative" if ($b < 0);
};
print "eval exception is printed and program runs further";
_____________
Now if you uncomment open (F, ...
the program will stop with the exception message at line 4
(Continue reading)
RSS Feed