On 6/1/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
snip
if (! $ftp ) {
snip
Ugh, use unless () {} rather than if (! ) {}.
snip
Even more preferred would be to throw an exception, and let the
calling code deal with it:
my $ftp = Net::FTP->new($remote_host) or
die "failed to connect to $remote_host\n";
Then in whatever code calls this command:
eval { connect_to_ftp() };
if ($@) {
print LOGFILE $@;
exit -1;
}
snip
This is the method that should be used in code that is longer than a
page or two or in production quality code. The "or do {}" trick is
just that: a trick. It is useful when you are prototyping or writing
some throwaway code, but it should not be done in production code.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/