for my $key (keys %Hash_filematches) { if ($key !=~ /grep (/$key/i, @files/) {#grepping for the key value and if it's not in the array then only proceed } }