neutron has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone,

I'm trying to create a program with basic portability and need to identify the program PATH. On my windows system it's C:\Perl\bin\perl.exe

I thought the easiest to determine this would be using $ENV{PATH} but when I do, I get several directories instead of just the one I'm looking for.

Any ideas???

Replies are listed 'Best First'.
Re: Finding Perl's program PATH
by jethro (Monsignor) on Oct 12, 2011 at 21:02 UTC

    The environment variable PATH contains all paths that have executables, i.e. are searched for executables when you input a command on the command line, it is not the path of the perl executable.

    What you want is $^X. See perlvar

Re: Finding Perl's program PATH
by BrowserUk (Patriarch) on Oct 12, 2011 at 21:03 UTC

    C:\test>perl -E"say $^X" C:\Perl64\bin\perl.exe

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thank you, both of you. This is perfect!!