Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Check for another program availability

by perlfan (Vicar)
on Apr 11, 2021 at 21:24 UTC ( #11131108=note: print w/replies, xml ) Need Help??

in reply to Check for another program availability

I'd avoid reimplementing how your shell uses $PATH. If this command is being run in a wrapper, it could be as simple as a commandline argument,
$ perl ./my/ $(which myprogram)

If you don't know the name of the program at first, then,
my $full_program = `which $program`; chomp $full_program;
Note: which will not "find" a program in $PATH for a file where -x is not also true. In other words, which requires the "found" file to have executable permissions by the effective user. So, yeah; don't try to reimplement which.

Replies are listed 'Best First'.
Re^2: Check for another program availability
by hrcerq (Scribe) on Apr 11, 2021 at 22:49 UTC

    I see, but, would that be portable? I mean, the which program itself may not be available.

      > portable
      You didn't say it had to be "portable on Windows".

        It doesn't. But even on Unix I have no guarantee that which will be installed on the system.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11131108]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2021-06-15 21:24 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (73 votes). Check out past polls.