Gunnar Hjalmarsson wrote:
Dr.Ruud wrote:
Gunnar Hjalmarsson wrote:
eval { $ssh2->connect($_) };
if ($@) {
warn "Unable to connect host $_: $@" and next;
}
That is the "old fashioned" way. You really need to use the return
value of eval to make sure.
I don't see anything about that in "perldoc -f eval". Instead it says:
"If there is a syntax error or runtime error, or a die statement is
executed, an undefined value is returned by eval, and $@ is set to the
error message. If there was no error, $@ is guaranteed to be a null
string."
This has been discussed many times before. The best known example is a
DESTROY with a die-ing eval, happening at leaving the eval bock scope.
Since you don't have control over that, you should always check the
result of the eval itself.
--
Ruud (the @@ guy)
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/