On 13/05/2013 18:08, David Precious wrote:
The usual way to catch exceptions is with an eval block or Try::Tiny
etc.
Basic example:
my $source_address = eval { $res->query(....); };
if ($@) {
# an error occurred - $@ will contain the message
# do something appropriate here
}
Testing $@ is basically always wrong, because it is a global variable
that can have changed value.
A rewrite:
my $source_address;
eval {
$source_address = $res->query(....);
1; # success
}
or do {
my $eval_error = $@ || 'Zombie Error';
...;
};
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/