walterf has asked for the wisdom of the Perl Monks concerning the following question:

Can the dos prompt be made to respect the (#!) first line of a perl script like UNIX does? BTW: I mean without forcing me to use some goofy extension on the file, like .pl, which I thought referred only to perl libraries only.

Replies are listed 'Best First'.
Re: Can windows do this?
by grep (Monsignor) on Jan 08, 2002 at 02:08 UTC

    The short answer is no. Windows ,as an OS, does not have the *nix philosophy of treat everything as a file. *nix will read the file as a executable if it marked so, then it will read head of the file to figure out what to do. Windows only uses file extensions to figure out what to do with file (i.e. .exe .com .bat).

    You can use different extentions like .prl or .p and associate them to perl



    grep
    grep> cd pub grep> more beer
(tye)Re: Can windows do this?
by tye (Sage) on Jan 08, 2002 at 02:22 UTC

    If you want to be able to run your script by saying "Flurge this.txt" instead of "Flurge.pl this.txt", then I suggest you use pl2bat or at least the documentation for it and use one of the other solutions described there (see (tye)Re: Calling a Perl filter script from command line or, even better, type "perldoc pl2bat" at your command prompt).

            - tye (but my friends call me "Tye")
Re: Can windows do this?
by talexb (Chancellor) on Jan 08, 2002 at 02:20 UTC
    ActiveState also provides something called pl2bat which makes a Perl script runnable. If you search in the recent messages you should turn it up.

    Update:Check out this node for more information. (That'll teach me to post before I'm ready.)

    --t. alex

    "Excellent. Release the hounds." -- Monty Burns.

      A couple of minor notes. First, ActiveState gets pl2bat with the Perl source code and distributes it the same as everyone else who distributes Perl.

      Second, the node you link to links to some really old documentation for pl2bat. Not even www.perldoc.com includes the documentation for pl2bat so I was forced to paste more up-to-date docs into a node here (and I linked to that elsewhere in this thread). The newer docs include a lot more information about the motivations for and alternatives to pl2bat.

              - tye (but my friends call me "Tye")
Re: Can windows do this?
by Moonie (Friar) on Jan 08, 2002 at 02:01 UTC
    I'm not quite sure what you're asking, so my answer may be a bit off base. But, you may want to look at this: - win32 shebang. Hope this helps. If not, please explain more!

    Good luck!
    - Moon
Re: Can windows do this?
by Starky (Chaplain) on Jan 08, 2002 at 02:40 UTC
    Only if you install Cygwin.

    However, if you are running CGI scripts in Apache on Windows, last I checked Apache will respect the shebang when running the script. Someone correct me if I'm out of date since it's been a couple years since I've worked with Windows and Apache together ....

      Apache will respect the shebang when running the script
      That is correct sir, yes now.

      --
      perl -pe "s/\b;([st])/'\1/mg"

      Just to elaborate -- Cygwin's bash and tcsh behave just like the 'nix-based originals. Try it, and you'll never go back to cmd.exe. (And be sure to check out Corion's econsole to feel the joy of transparent console windows in Win32land.)

      -- Frag.
      --
      "Just remember what ol' Jack Burton does when the earth quakes, the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Jack Burton just looks that big old storm right in the eye and says, "Give me your best shot. I can take it."