I guess if you wanted to check if $garbage is a valid exe before executing it you could do something like the following. I'm not sure what the behavior is on 5.002 with File::Spec - can probably replace that with split(/:/,$ENV{'PATH'});
use File::Spec;
sub valid_exe {
my $exe = shift;
for my $dir ( File::Spec->path() ) {
my $f = File::Spec->catfile($dir,$exe);
if( -e $f && -x $f ) { # it is a valid exe
return 1;
}
}
return 0;
}
Essentially what which will do for you, your call if it is cleaner. |