http://www.perlmonks.org?node_id=860473


in reply to Help with my rookie logic

opendir (DIR, $filepath) || die("Cannot open directory");
should be modified to
opendir (DIR, $filepath) || die("Cannot open directory '$filepath': $!");

Similarly,
print "$file does not match\n";
could be modified to
print "'$file' does not match '$subname'\n";