"Chas. Owens" schreef:
> Adarsh Srivastava:
>> 1. Perl doest seem to catch errors like divide-by-zero error. Eg:
>> for an input expression like 99 / 0, it simply displays nothing as
>> output. (no errors thrown).
>
> Not true. If you aren't seeing the errors then you aren't checking $@
> like I did in my example.
Sorry Chas, for hijacking your reply.
I never understood why checking $@ is done, when checking the eval
return value itself is available (and it always is, or can be made so).
eval {
...
1;
} or do {
...
};
The $@ can be set in many ways. Some coders even test $@ with regexes.
Let's try to get rid of all that, just as with bareword filehandles and
2-argument opens.
This means that you should rewrite
my $dbh = eval { ... };
if ($@) {
....; # error
}
to something like
my $dbh;
eval {
$dbh = ...;
1;
} or do {
...; # error
}
(or use an if/else construct of course)
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/