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
    posting.

    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"

    But,
    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.

    Regards

    Nick
     
    Test Test., Apr 28, 2006
    #1
    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";

    exit(0);


    I just tried changing the first line so I now have

    #!/usr/local/bin/perl
    use strict;
    use warnings;

    print STDERR "\nHello world\n";

    exit(0);

    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
    #2
    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
    #3
  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
    #4
  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

    http://httpd.apache.org/docs/2.0/mod/core.html#scriptinterpretersource

    Use

    ScriptInterpreterSource Registry-Strict

    in your httpd.conf file, and add

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI]
    "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).

    Sinan

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

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Apr 28, 2006
    #5
  6. These are two solutions. First the simple:

    http://groups.google.com/group/comp.lang.perl.misc/msg/5d01d5affb0294e8

    and then a more elegant(?):

    http://groups.google.com/group/comp.lang.perl.misc/msg/46026827a583f19d
     
    Gunnar Hjalmarsson, Apr 28, 2006
    #6
  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
    #7

  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'
    or
    the not-as-good-as-use-warnings '-w'

    would be accurate.
     
    Tad McClellan, Apr 28, 2006
    #8
    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.