Lars Madsen <> wrote in
news:434c1635$0$7637$:
> normally I only work on Linix systems, but now I have to write
> a test script (for some LaTeX stuff) that needs to be able to run on
> unix systems, MAC OS X and Windows.
>
> I need to test whether certain programs are available on a particular
> system. Say, we want to know if 'ps2pdf' exists on this system. How
> would you create a perl script that are able to run on Windows, Mac OS
> X and Linux, that will tell you if a given external program is
> available on this system?
Do you want to find the binary in the path, or anywhere on the hard
drive? If you only want to find it in the path, your task is simple:
#!/usr/bin/perl
use strict;
use warnings;
sub is_ps2pdf_in_path {
my $s = `ps2pdf`;
return ( -1 < index $s, 'Usage' );
}
printf "ps2pdf: %s\n",
( is_ps2pdf_in_path() ) ? 'found' : 'not found';
__END__
On the other hand, for more general usage, I would suggest a
configuration dialog during installation asking the user to specify the
locations of the binaries you need instead of searching the hard drive
for possibly a very long time for each binary.
Sinan
--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html