use File::Basename; use File::Spec; # grab the dirs. my @dirs = grep { -d $_ } glob '/app/perform/workspace/htdocs/node_reports/*'; # look for any dirs that do not have the desired file in them. my @missing_business_use_dirs = grep { # find the node name (it's the base name of the current directory) my $node = basename($_); # check if the desired file exists - keep the ones where it doesn't. not -e File::Spec->catfile($_, "business_use.$node"); } @dirs