You might want to examine your regex, you're using a dot
inside the filename, which will match one of anything. You
may want to escape it using a backslash (\), to make it a
literal match. Or better yet, don't use a regex at all,
try using eq.
Also, File::find() will execute getpm() for
each file it finds underneath $fpath.
More than likely, the first file it's finding is not readme.txt,
so it's printing "File not Found", and exiting.
If you'd like the behaviour of printing "File Not Found" if
there is no match, a better idea would be to push any file matches onto
an array, then test the array after you're done directory traversing:
#!/usr/bin/perl -w
use strict;
use File::Find;
use vars qw(@FILES);
find(\&getpm, '.');
unless(@FILES) {
print "File not Found\n";
exit;
}
print "$_\n" for @FILES;
sub getpm {
push @FILES, $File::Find::name
if -f && $_ eq 'readme.txt';
};