note
Tux
<p>The suggested [metamod://File::Which] is probably *the* solution you want.</p>
<p>The suggested [metamod://File::Spec] is probably (very) good to get used to when writing code that should work on all types of OS's.</p>
<p>I want to add that returning the actual path of the tool/program/script/file is a lot more useful than returning <c>1</c>.</p>
<p>I also want to say that your approach is less than perfect as you do not skip empty <c>$PATH</c> elements and elements that do not exist or are not a directory. This matters a lot if you are dealing with environments where the environment cannot be trusted. I'd suggest (ignoring both mentioned modules):</p>
<code>
use List::Util qw( first );
sub available {
my $prog = shift;
first { -x "$_/$prog } grep { m/\S/ && -d } split m/:+/ => $ENV{PATH};
}
</code>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-200365">
<br />
Enjoy, Have FUN! H.Merijn
</div></div>
11131091
11131091