my $pdfs = get_pdfs(); pp $pdfs; # pp sample from data in text file { "testa.pdf" => 0, "testb.pdf" => 0, } ... for my $file ($rule->in(@search_dirs)){ my ($filename, $path) = fileparse($file); if (exists $pdfs->{$filename}){ my $pages = get_pagecount($file); print " $filename,$pages,$path\n"; # print to file ++$count; }else { print " File $filename not found in $path\n";} }; ..