Perl execution from command line question
Asked Answered
S

4

4

I replaced ActivePerl with Strawberry Perl on my WinXP last week.

I found I must run my Perl script with the command of perl myperl.pl; otherwise I only need run myperl.pl before install Strawberry. How can I only run myperl.pl as before?

I checked my environment configuration as below.

C:\> Path

C:\Program Files\ActiveState Komodo Edit
5\;C:\Perl\site\bin;C:\Perl\bin;C:\Perl\bin\;C:\Program Files\CodeSynthesis
XSD 3.2\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft
SQL Server\90\Tools\binn\;C:\Program Files\Common Files\Thunder Network\KanKan
\Codecs;C:\strawberry\c\bin;C:\strawberry\perl\bin`

Strawberry Perl path already listed in the Path value after install successfully.

Anything I missed? Thank you for your suggestion.

Salerno answered 10/6, 2010 at 9:56 Comment(0)
S
11

Try from command prompt:

assoc .pl=PerlScript
ftype PerlScript=c:\strawberry\bin\perl.exe %1 %*

-- kmx

Strawworm answered 10/6, 2010 at 11:15 Comment(2)
It doesn't work on my side. I ran the two lines from windows command window successfully. But I tried to run my Perl script, It still failed. I don't know why?Salerno
It works. I realized that my computer Perl Script Path should be c:\strawberry\perl\bin\perl.exe in the command. microsoft.com/resources/documentation/windows/xp/all/proddocs/…Salerno
L
8

You need to associate .pl file extension with Strawberry Perl's executable (it's a Windows thing, not a Perl thing).

To do so, there are a couple of ways (you can google or ask on ServerFault for the best one or full list), but the one I usually use on XP is:

  • Open any folder Windows Explorer
  • Go into "Tools" menu, and click on "File Types" tab in the resulting dialog
  • Find "PL" extension in the list
  • If it's there, correct the associated executable to be Strawberry Perl's .exe by clicking on "PL" line and clicking "Change" button
  • If it's not in the list, click "New" button, type in PL extension in the form and click "OK". Then close the whole dialog, and re-open it again. The "PL" extension will now be in the list, so click on it and click "Change" button

In case I messed up, here's the official instructions from Microsoft:

http://support.microsoft.com/kb/307859

UPDATE Please see kmx's answer - his method is all-command-line and as such seems much more preferable to me that GUI blundering... I confirmed that it works too (without parameters, at least)

Lumbricalis answered 10/6, 2010 at 10:56 Comment(2)
@Nano - please see kmx's answer - his method is all-command-line and as such seems much more preferable to me... I confirmed that it works too!Lumbricalis
Use the proper technique: See kmx's amswerMaurits
H
3

You might need to put the .PL extension into the PATHEXT environment variable. This will make .pl files work with the PATH variable.

Type

set PATHEXT

to see if you're set up. If you're not, then go to My Computer->properties->Advanced and press the "Environment Variables" button on the bottom of the tab. There you can add .PL to the PATHEXT variable.

OR you could just set it in some batch file that you run to initiate cmd:

set PATHEXT=%PATHEXT%;.PL
Handset answered 10/6, 2010 at 13:39 Comment(1)
This is not the answer to the question, but it is noneless an other useful tip that will help the poster.Spew
G
0

For completeness here's 2 other methods that don't make a .pl script executable, but you could use them to make your perl script into an executable.

  • pl2bat which is suppose to create a wrapped version of your .pl into a .bat file which would be executable on a windows system. I haven't tried this so YMMV.
  • pp, part of the PAR::Packer module which I have used before works pretty well at rolling your perl scripts into executables.
Glasses answered 22/1, 2012 at 2:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.