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!