FAQ 3.22 How can I get "#!perl" to work on [MS-DOS,NT,...]?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
This is an excerpt from the latest version perlfaq3.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .


3.22: How can I get "#!perl" to work on [MS-DOS,NT,...]?

    For OS/2 just use

        extproc perl -S -your_switches

    as the first line in "*.cmd" file ("-S" due to a bug in cmd.exe's
    "extproc" handling). For DOS one should first invent a corresponding
    batch file and codify it in "ALTERNATE_SHEBANG" (see the dosish.h file
    in the source distribution for more information).

    The Win95/NT installation, when using the ActiveState port of Perl, will
    modify the Registry to associate the ".pl" extension with the perl
    interpreter. If you install another port, perhaps even building your own
    Win95/NT Perl from the standard sources by using a Windows port of gcc
    (e.g., with cygwin or mingw32), then you'll have to modify the Registry
    yourself. In addition to associating ".pl" with the interpreter, NT
    people can use: "SET PATHEXT=%PATHEXT%;.PL" to let them run the program
    "install-linux.pl" merely by typing "install-linux".

    Under "Classic" MacOS, a perl program will have the appropriate Creator
    and Type, so that double-clicking them will invoke the MacPerl
    application. Under Mac OS X, clickable apps can be made from any "#!"
    script using Wil Sanchez' DropScript utility:
    http://www.wsanchez.net/software/ .

    *IMPORTANT!*: Whatever you do, PLEASE don't get frustrated, and just
    throw the perl interpreter into your cgi-bin directory, in order to get
    your programs working for a web server. This is an EXTREMELY big
    security risk. Take the time to figure out how to do it correctly.


The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in

Re: FAQ 3.22 How can I get "#!perl" to work on [MS-DOS,NT,...]?

Quoted text here. Click to load it
Quoted text here. Click to load it

This part of the answer seems quite antiquated and is missing critical

None of MS-DOS, Win95 or NT are playing any role in todays computing any
longer. Suggest to replace those with Windows XP and Vista.
And you don't modifying the registry. Well, at least not directly.
Besides, running regedit for registering the Perl interpreter is like
using a sledge hammer to make an omelet.

Correct way is to change the file type association of *.pl files to run
the command
    "[PathToPerlInterpreter]\perl.exe" "%1" %*
The "%1" %* are critical (and are missing from the current answer)
because without them command line parameters are not passed to the Perl

How to formulate this into two or three comprehensive sentences for the
FAQ is a different question. My English is probably not sufficient for


Re: FAQ 3.22 How can I get "#!perl" to work on [MS-DOS,NT,...]?

Jürgen Exner wrote:

Quoted text here. Click to load it

Technically, XP is NT 5.2 and Vista is NT 6.0 (whatever NT is supposed
to mean anymore).  They are built on the basis of NT's design, so NT is
still playing a role.  Sorry, couldn't help it. :-)
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Re: FAQ 3.22 How can I get "#!perl" to work on [MS-DOS,NT,...]?

Quoted text here. Click to load it

Send me the patch that includes the latest information. I'm not a
Windows person, so I don't track Windows stuff.

Site Timeline