my @files=$ftp->ls or die "Cannot list current directory: $@"; foreach my $x_files(@files) { # Tried that but it exits completely and never gets to the next if #next unless ($file_path.$x_files =~ m/\.xml$/); #I am loking for new files only, it works for new files only but ignores the rest of the check, has to be a better way here if ((-e $file_path.$x_files ) && (-z $file_path.$x_files > 0) && ($file_path.$x_files =~ m/\.xml$/) ) { # Print this just for sanity check! print "File $x_files already exists!
"; print "File $x_files has ) size!
"; print "File $x_files isn't a xml file!
"; }else{ $ftp->get($x_files, "$file_path".$x_files) or die "Can't fetch $x_files: $!\n"; push @all_files, "$file_path".$x_files; } #print "$x_files
"; } $ftp->quit;