use strict; use warnings; my @files_to_check = ( 'abc.txt', 'xyz.txt', 'efg.txt' ); # list of files to check my @directory_listing = $ftp->ls($dir); my %files_on_FTP_server; foreach my $file (@directory_listing) { # extra processing here? $files_on_FTP_server{$file} = 1; } foreach my $file (@files_to_check) { if ( ! $files_on_FTP_server{$file} ) { print "File $file is missing\n"; } }