Hi monks,

Just want to ask if there's a function or any other way I
can get the path of installed perl.exe to avoid typing the
hardcoded path in my perl source code?

Here is my current code(I've edited sample code in Perl Cookbook):

Win32::Process::Create($Win32::Process::Create::ProcessObj, 'C:/Perl/bin/perl.exe', #<--THIS LINE IS MY CONCERN 'perl xdos.pl', 0, # Don't inherit. DETACHED_PROCESS, # ".") or # current dir.

I'm trying to remove DOS Window from Perl Tk program which
I succesfully did but I couldn't find a built in funtion to
get the path of perl.exe to supply the 3rd parameter of
Win32::Process::Create().

My perl application will be used in different PC and Perl
was installed in different paths and drives in some PCs. So
I need to not use the hardcoded path.

I am planning to use the "ftype perl" in command line using
system() to get the perl.exe path but I think it is better
to use perl's way since "ftype" is not available in other
OS.

I'd tried to search functions and Environment variables but
I couldn't find what I want.

I hope there is a way other than "ftype perl".

Please lend me the wisdom for this problem.

-toastbread


In reply to Avoiding Hardcoded path of Perl.exe in coding by toastbread

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.