Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Net::FTP - Check if file already exists locally before download

by hippo (Bishop)
on Feb 12, 2019 at 10:52 UTC ( [id://1229785]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP - Check if file already exists locally before download

Is this what you are looking for?

for my $file (@set_of_files) { $ftp->get ($file) unless -e $file; }
  • Comment on Re: Net::FTP - Check if file already exists locally before download
  • Download Code

Replies are listed 'Best First'.
Re^2: Net::FTP - Check if file already exists locally before download
by mitabrev (Novice) on Feb 12, 2019 at 12:04 UTC
    Thanks! Exactly what I thought, couldn't see the easiest solution.
Re^2: Net::FTP - Check if file already exists locally before download
by mitabrev (Novice) on Mar 11, 2019 at 21:24 UTC

    Hi Monks,

    I got a follow up question. Is it possible to use the same command to check if file exists in two or more different directorites?

    for my $file (@set_of_files) { $ftp->get ($file) unless -e /dir1/$file; }

    so basically to check:

    unless -e /dir1/$file unless -e /dir2/$file

    something like that?

    Thanks again.

      for my $file (@set_of_files) { $ftp->get ($file) unless (-e "/dir1/$file" or -e "/dir2/$file"); }

        It works.

        Guess I tend to overthink and overcomplicate simple things.:)

        Thanks again!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found