while (<$fh>) { if (/^M/) #What is this ? { chomp; my $filename = $_; $filename s,.*/,,; #strip off leading path info $seen->{$filename}++ if( $filename =~ /pdf/ || $filename =~ /msi/) } } if (! exists $seen->{'people.pdf'} ) { print "People not found\n"; } if (! exists $seen->{'animal.pdf'} ) { print "animal not found\n"; } if (! exists $seen->{'setup.msi')) { print "MSI file not found\n"; } exit;