navalned has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to push all executibles in my $PATH to an array, but doesn't seem to work as expected.
use IO::Dir; my @cmds; my @paths = split /\:/, $ENV{PATH}; foreach my $path (@paths) { tie my %dir, 'IO::Dir', $path; foreach my $file (keys %dir) { if (-f -x $file) { push @cmds, $file; } } undef %dir; } foreach my $cmd (@cmds) { print $cmd . "\n"; }
Here is the output I'm getting:
h2xs
I guess its kinda cool it found a perl related executable, but I was hoping for more.
Edgar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: file test results not as expected
by toolic (Bishop) on Nov 21, 2020 at 23:33 UTC | |
by navalned (Beadle) on Nov 22, 2020 at 00:00 UTC | |
|
Re: file test results not as expected
by Fletch (Bishop) on Nov 22, 2020 at 03:13 UTC |