in reply to Re^2: searching files
in thread searching files

You are not checking for existence of a file path, but the result of regex match against $_.

I think you would be better off (for some definition of "better") with Path::* solution suggested earlier instead of rolling a solution on your own. Also, please do the RTFM.