foreach my $file (@strings) { next unless -e $file; # ignore this file if it doesn't exist # your code here }