Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: file test results not as expected

by toolic (Bishop)
on Nov 21, 2020 at 23:33 UTC ( #11123995=note: print w/replies, xml ) Need Help??


in reply to file test results not as expected

You need to use the full path to the file for the file test. Change:
if (-f -x $file) {
to:
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

Replies are listed 'Best First'.
Re^2: file test results not as expected
by navalned (Sexton) on Nov 22, 2020 at 00:00 UTC

    Thats cool and works well. You can try this for a 5 sec improvement at least on my system:

    grep { -x "$path/$_" && !-d _ }

    Saves a lot of stat() calls.

    Thanks for the answer. I think I knew the answer deep in the recesses of my brain but couldn't see it.
    Edgar

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-11-27 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?