jcalhky has asked for the wisdom of the Perl Monks concerning the following question:

How do I check to see if my remote file exists in the local directory when I'm doing a FTP. I don't want to use the Net::FTP:Common module, because I don't want to use a hash. I rather just use Net::FTP.
  • Comment on Checking for Duplicate Files during an FTP

Replies are listed 'Best First'.
Re: Checking for Duplicate Files during an FTP
by davidrw (Prior) on May 05, 2005 at 22:08 UTC
    What do you mean by "don't want to use a hash"? Are you referring to the fact that the dir() method in Net::FTP::Common returns a hash? If so, couldn't you just ignore all the extra info it gives you? There is also a ls() method that returns an array.
    my $ez = Net::FTP::Common->new(\%common_cfg, %netftp_config); ez->login or die "cant login: $@"; my %retval = $ez->dir; my @names_only = keys %retval; my @files_only = grep( $retval{$_}->{perm} !~ /^d/, keys %retval );
Re: Checking for Duplicate Files during an FTP
by ikegami (Patriarch) on May 05, 2005 at 22:10 UTC
    You need to get a listing of the files on the server (using the ls or dir method) and check your file name against it (perhaps by using grep Perl function).