Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Using Perl, some Windows version and #!usr/bin/perl, WHY?

by wolfi (Scribe)
on Mar 21, 2004 at 02:02 UTC ( [id://338398]=note: print w/replies, xml ) Need Help??


in reply to Using Perl, some Windows version and #!usr/bin/perl, WHY?

yeah - normally, windows doesn't care about #! lines (so long as the perl program doesn't either), since windows thinks in terms of file-extensions and associations. Soooo... why use it on windows? Well...

~ servers (even those on localhost windows) may require it. (My apache gets upset when i omit my #!C:\perl\bin\perl.exe line.)

~ most script problems are the same for *nix users or windows people. So, it's helpful to have one method in the posts (and easier to search for).

~ i'd think most perl-scripts are eventually written with the idea, that they'll eventually end up on a *nix platform. Like etcshadow said - it's a good habit.

~ if it's more trouble to delete/re-add/delete/re-add it as needed - rather than just having it to begin with... why omit it?

just my take. I'd rather be writing perl code, than trying to figure out, if i needed the shebang line or not "am i only going to use this thru the prompt... or do i intend to use it thru the server...?"

including it is just easier. :-)

  • Comment on Re: Using Perl, some Windows version and #!usr/bin/perl, WHY?

Replies are listed 'Best First'.
Re: Re: Using Perl, some Windows version and #!usr/bin/perl, WHY?
by strat (Canon) on Mar 21, 2004 at 12:14 UTC

    Quote: TStanley

    If I remember correctly, both Windows and Unix look on the shebang line for any switches passed in(i.e. the -w or -i switches)

    Not exactly; under Unix the shell cares for the shebang, but the Windows shells (cmd.exe, command.com) don't know anything about shebangs (only cygwin knows, off course). Perl itself cares for the parameters like -w, -n, -i, -p, ....


    Quote: wolfi

    ~ servers (even those on localhost windows) may require it. (My apache gets upset when i omit my #!C:\perl\bin\perl.exe line.)

    For Apache 1.3, there exists an option in httpd.conf which is called ScriptInterpreterSource registry. If you activate this line, Apache looks for the file extention when executed as CGI (e.g. cgi), looks up in the registry what to do with a files with the extention .cgi ... well, execute it with perl... and does it. Then you can use whatever shebang you like. I like to use this when I'm developing webpages under Windows where the production server is Linux/Unix. Another benefit is that you can test more perl-versions by just assigning another perl-interpreter to .cgi or .pl and need not changing ton's of files...

    Btw: You can associate an ending with an interpreter under windows in the shell the following way:

    assoc .pl=Perl assoc .cgi=Perl ftype Perl="D:\Programs\gnu\perl809\bin\perl.exe" "%1" %*
    (Dont forget the " in ftype, or you will get funny results if there are spaces within the paths...)

    For Apache2 there exists a similar command, but I don't know it by heart

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      well, ya learn something new every day ;-)

      thank you for the info strat. I've done a decent amount of editting of the httpd.conf but never come across using that ScriptInterpreterSource argument.

      will have to pay more attention to that in the future. Thanks again ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://338398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found