in reply to file test results not as expected
You need to use the full path to the file for the file test. Change:
to:if (-f -x $file) {
if (-f -x "$path/$file") {
This is how I do it: Finding commands in Unix PATH:
findcmd is a script which searches through the directories
in the Unix PATH variable for executable files
In Section
Seekers of Perl Wisdom