Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: VB "On Error" Equivalent in Perl

by erroneousBollock (Curate)
on Nov 29, 2007 at 01:28 UTC ( #653737=note: print w/ replies, xml ) Need Help??

in reply to Re: VB "On Error" Equivalent in Perl
in thread VB "On Error" Equivalent in Perl

eval { $ftp = Net::FTP->new("", Debug => 0) or die "Cannot connect to $@"; last TRY; }
I'm curious about your use of $@ om the second line of the eval. How would $@ be set without causing an exception that would throw control outside the eval?

If the die "Cannot ..." ever occurs, wouldn't $@ be empty?

Surely $@ is only useful outside the eval?

Also, eval {} is a statement and should be followed by a semicolon if further statements are to follow in the current block. Your code doesn't compile.


Comment on Re^2: VB "On Error" Equivalent in Perl
Select or Download Code
Replies are listed 'Best First'.
Re^3: VB "On Error" Equivalent in Perl
by wind (Priest) on Nov 29, 2007 at 01:41 UTC
    That is explained in the documentation for Net::FTP.
    If the constructor fails undef will be returned and an error message will be in $@.
    All other Net::FTP methods save their error message in $ftp->message.

    I've also sometimes wondered about the logic of this. Nevertheless, that's the way it is.

    - Miller

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://653737]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2015-11-26 17:17 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (704 votes), past polls