http://www.perlmonks.org?node_id=11131091

hrcerq has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I need feedback on this... In order to run a Perl program, I must check for the availability of another program (i.e. it's in the PATH). So I've created a subroutine for this (which returns 0 for "not found" and 1 for "found"), and I'm not sure if this is the best option. Here's the code:

sub available { my $program = shift; for my $pathdir (split /:/, $ENV{PATH}) { return 1 if -x "$pathdir/$program"; } return 0; }

I'd like to know if it's inefficient, and if there's a core module that already takes care of such tasks. Found nothing related on the FAQs.