http://www.perlmonks.org?node_id=653737


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

eval { $ftp = Net::FTP->new("some.host.name", Debug => 0) or die "Cannot connect to some.host.name: $@"; 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.

-David