On Tue, Jul 23, 2002 at 07:46:36PM -0700, Michael G Schwern wrote:
> my @PATH = split/:/,$ENV{PATH};
^ ^
This is
> while ($command = shift) {
> print "Checking for command: $command... ";
> my $found = undef;
> for my $path (@PATH) {
> if ( -x "$path/$command" ) {
^ ^
all going
> push @answer, "$path/$command";
^ ^
to need
> $found = "yes ($path/$command)\n";
^ ^
some more
> }
> }
> if (defined($found)) {
> print $found;
> } else {
> print "not found\n";
> exit
> }
> }
> return @answer;
> }
work to make it usefully portable.
ie where does the OS keep the user's path, how do you separate it, using
File::Spec to join paths and whether one should tack $Config{exe_ext} onto
the end of command names. And that's all independent of VMS, Windows and other
beasts having commands with different names from Unix.
Nicholas Clark
--
Even better than the real thing: http://nms-cgi.sourceforge.net/