http://qs321.pair.com?node_id=172336

hsmyers has asked for the wisdom of the Perl Monks concerning the following question: (programs and processes)

How do you make it so that you don't have to type the '.pl' extension when running perl scripts on NT (or W2k or XP)?

Originally posted as a Categorized Question.

  • Comment on How do you run a perl script without typing the extension on NT?

Replies are listed 'Best First'.
Re: How do you run a perl script without typing the extension on NT?
by hsmyers (Canon) on Jun 06, 2002 at 20:21 UTC

    Basically this is a three step process:

    1. ASSOC .pl=PerlScript
    2. FTYPE PerlScript=perl.exe "%1" %*1
    3. set2 PATHEXT=.pl;%PATHEXT%

    1. The double quotes around the '%1' allow there to be spaces in the path to your script. SEE http://aspn.activestate.com/ASPN/Mail/Message/activeperl/1229724

    2. The permanent solution would be to right-click on 'My Computer' and select the 'Environment' tab. A change to 'PATHEXT' there will stick!

    Edit by tye

Re: How do you run a perl script without typing the extension on NT?
by wil (Priest) on Jun 06, 2002 at 20:07 UTC
    You shouldn't have to do this anymore with Perl for Windows, as it automatically updates the Registry, so as long as you name your files with an appropriate extension - .pl or maybe .cgi then Windows should automatically detect these as Perl scripts and just treat your shebang line as a comment.

    However, make sure that you uncomment the following line in your httpd.conf file to ensure that Apache looks up the correct location within the Windows Registry rather than refering to the shebang line.
    ScriptInterpreterSource registry
    This is documented at the Apache website.

    - wil
Re: How do you run a perl script without typing the extension on NT?
by Rich36 (Chaplain) on Jun 06, 2002 at 20:10 UTC
    You can use pl2bat.
    DESCRIPTION
        This utility converts a perl script into a batch file that can be
        executed on DOS-like operating systems. This is intended to allow you
        use a Perl script like regular programs and batch files where you jus
        enter the name of the script probably minus the extension plus any
        command-line arguments and the script is found in your PATH and run.
    
Re: How do you run a perl script without typing the extension on NT?
by jsprat (Curate) on Jun 06, 2002 at 20:27 UTC
    As long as .pl files are associated with the perl interpreter, set PATHEXT=%PATHEXT%;.PL at a command prompt will do it temporarily. You can set the PATHEXT environment variable permanently in the system properties capplet.

    Originally posted as a Categorized Answer.