Linux and Win32 compatability

Discussion in 'Perl Misc' started by Test Test., Apr 28, 2006.

  1. Test Test.

    Test Test. Guest

    My most humbl apolgies if this is not the right place for this

    My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    my Perl Scripts start with the usual line:
    #!"C:\Program Files\Perl\bin\perl.exe"

    My Web host is Linux based, with both Perl and Apache. So, the top
    line my Perl scripts at my ISP site is: #!/usr/bin/perl --

    So far, this top line is the only line which is different between my
    local Win2K site and the online website.

    This question must have been asked before, but, is there any way of
    making the two scripts compatable so that I don't need to track 2
    versions just becuase of the top line?

    Thanks in anticipation.


    Test Test., Apr 28, 2006
    1. Advertisements

  2. You shouldn't need the shebang line at all under Windows provided your
    path and the file extension association are set up correctly. I am
    currently working under XP but used Win2000 until September last year
    and this works just fine for me

    # No shebang !!
    use strict;
    use warnings;

    print STDERR "\nHello world\n";


    I just tried changing the first line so I now have

    use strict;
    use warnings;

    print STDERR "\nHello world\n";


    and this also runs with no problems.

    As far as I am aware any line starting with a hash will be treated as a
    comment under windoze.
    niall.macpherson, Apr 28, 2006
    1. Advertisements

  3. Test Test.

    prawn Guest

    *Ding*. I always put a unix stylee shebang on my win32 perl scripts. It
    saves loads of grief when porting code.
    prawn, Apr 28, 2006
  4. Any line starting with a hash will be treated as a comment in Perl!

    AFAIK the Perl interpreter in Windows does look at the shebang line in
    order to detect command line arguments, e.g. the deprecated '-w' would
    be detected. The command path, however, is ignored.
    Josef Moellers, Apr 28, 2006
  5. The other responses to your post fail to take into account the fact that
    Apache on Windows does pay attention to the shebang line.

    To keep the shebang line for the Unix system, but tell Apache on Windows
    not to pay attention to the shebang line, see


    ScriptInterpreterSource Registry-Strict

    in your httpd.conf file, and add

    Windows Registry Editor Version 5.00

    "command"="c:\\opt\\perl\\bin\\perl.exe -T \"%1\""

    to your registry (replace the path to perl.exe with whatever is
    appropriate for your system).


    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    A. Sinan Unur, Apr 28, 2006
  6. These are two solutions. First the simple:

    and then a more elegant(?):
    Gunnar Hjalmarsson, Apr 28, 2006
  7. Test Test.

    Test Test. Guest

    Well, that may work when running a simple Perl script as above from a
    command line. But my script is a Server Side Include (SSI) file which
    needs some setup in the Apache Web Server. Making the modfication you
    suggest just gives me [an error occurred while processing this
    directive] on my webpage.
    The Path to the perl.exe is set in my PATH. But Apache web server
    doesn't seem to have anywhere to associate .pl scripts to the perl.exe
    interpreter. It mentions that *.pl files are CGI scripts, but not
    which interpreter specifically will be started by Apache when the
    script is invoked.

    But, thanks for your help anyway.

    Anyone else know how to do this?
    Test Test., Apr 28, 2006

  8. The term "deprecated" has a precise meaning, and I am pretty
    sure that we cannot apply it to the warnings switch yet.

    the superceded '-w'
    the not-as-good-as-use-warnings '-w'

    would be accurate.
    Tad McClellan, Apr 28, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.