Beginners@Perl.Org:

I'm working on some Perl code that generates Makefile code that invokes external programs. I'd like my code to check if a command is installed before writing to the Makefile (so that Make doesn't explode when the command is missing). I'd like my code to work on all the CPAN tester platforms -- GNU/Linux, *BSD, Win32, Mac, etc..


I've been going around in circles with two basic approaches:

1. Use Capture::Tiny::capture around a system() call (string and/or list form) and look at the $stdout, $stderr, the return value, and/or $!.

2.  Use eval() around backticks and look at the return value and/or $...@.


I've thought about searching the PATH, but that won't work for shell built-in commands.


I've yet to find one approach that works correctly for all programs on all platforms.


I've STFW, CPAN, Perl Monks, etc., but haven't found a solution to what should be a classic need.


What is the proper, platform-independent Perl way to determine if a program is installed?


Bonus question: what is the proper, platform-independent Perl way to determine if a shell built-in command is available?


TIA,

David


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to