in reply to Re: NET::FTP error question
in thread NET::FTP error question

A line by line critique:
use Net::FTP; # You should 'use strict' if the final script is # going to be any longer than 5 or 10 lines, # which would make the next line 'my $ftp = ...'. # Also, according to the Net::FTP docs, connect # errors are reported in $@, not $! $ftp = Net::FTP->new("$host", debug => 1) or die "Host: $!"; # Error messages after new are reported in the # message() method ($ftp->message, and don't put it inside # quotes since methods won't get interpolated inside # quotes). This method is documented in Net::Cmd, which # Net::FTP inherits from. # Are $user and $pass set to anything? $ftp->login($user,$pass) or die "Login: $!"; # Same comment as above. $ftp->cwd() or die "Dir: $!"; # Are $file and $dir set to anything? # Does $dir exist on the local system? # Does $file exist in the current directory # on the remote system? # Is there a permission problem? # And you don't need to backwhack the "/" $ftp->get("$file","$dir\/$file") or die "File: $!"; $ftp->quit;
Also, in general, you don't need to put quotes around just a single variable, e.g. "$file", though some people consider it a matter of preference.
And again, Use strict and warnings :-)

Replies are listed 'Best First'.
Re: Re: Re: NET::FTP error question
by Anonymous Monk on Nov 21, 2001 at 23:39 UTC
    Just wanted to say thanks to runrig, the line by line critique pointed out a (sadly) basic error I was having problems with doing something similar, but not directly related to this thread. When people take the time to fully explain like this it is amazing how much good can result, even on off topic matters. Thanks for your excellent commentary!
    -Mike Gucciard
    -Neophyte Perl Coder
    -owner@funevilpeople.org