Perl execution from command line question

你说的曾经没有我的故事 提交于 2019-12-01 06:47:52

Try from command prompt:

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

-- kmx

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)

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

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!