Under Windows, the path to Perl that we typically find as the first line is irrelevant. Windows will use the program that you have associated with say the .pl extension. So this is a lot messier than with Unix!

To set this up in Windows there are 2 steps:

1)Setup the association between the .pl extension and an actual program. Search for "associate extension" in Windows Help for the details. Now you will be able to "click on" a Perl program icon to run it.

To view associations from the command line, use the assoc Windows command (or of course use the GUI method above):

C:\Projects>assoc | grep -i perl .perlnet=PerlNET.Project .pl=Perl .pls=PerlScriptFile
2)Next, you need to tell Windows shell that files ending in .pl are executable files. This is needed so that you can type in the name of a Perl file (something.pl) from the command line. This is done via the PATHEXT environment variable. Search for "environment" in Windows Help and look at "Add or change the values of environment variables".
When you get done PATHEXT will look like this:
C:\Projects>env | grep EXT PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1;.pl
To use a different version of Perl to run, at the command line you must type the name of the Perl.exe that you mean, perhaps like: >perlv58 xxx.pl or >perlv510 xxx.pl. I suppose that if you are going to do this a lot, you could set up a .pl58 and a .pl510 file extension for different versions. But, no under Windows, the .pl file itself will not know which Perl interpreter to run.

Oh, I guess you could also make a .bat file that pre-pends the PATH with the path name of the version of Perl that you want to use, that way it will be found first when it sees a .pl file. Also, on Windows you can make different shortcuts to the command line shell with different environment variables. So if you want to work with say Perl 5.10 instead of Perl5.8, you just start a different command line environment.

This is one other bit that you should know...Although the path to Perl is not used under Windows, the flags after it are used. For example: #!/usr/bin/perl -w The -w flag turns on warnings.

So if you are not using multiple versions of Perl under Windows, just associate the .pl extension as shown above. The Windows Perl will ignore the path after #! that you are using under Unix, but will use the switches (like -w or whatever).

This was wordy, but I hope clear enough to understand.


In reply to Re: path to perl install directory by Marshall
in thread path to perl install directory by srinikar

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.