Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Check for another program availabilityby Tux (Canon) |
on Apr 11, 2021 at 07:32 UTC ( [id://11131101]=note: print w/replies, xml ) | Need Help?? |
The suggested File::Which is probably *the* solution you want. The suggested File::Spec is probably (very) good to get used to when writing code that should work on all types of OS's. I want to add that returning the actual path of the tool/program/script/file is a lot more useful than returning 1. I also want to say that your approach is less than perfect as you do not skip empty $PATH 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):
Enjoy, Have FUN! H.Merijn
In Section
Seekers of Perl Wisdom
|
|