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

Hi,

I'm trying to get my Perl script to run under Apache/CGI on Windows.

With latin-based pathnames the shebang notation works fine under all Apache versions for determining the perl executable location, e.g.:
#!C:/Program Files/SpatialDirect/Perl/bin/perl.exe

If I then introduce Japanese character data into the path I can only get the script to successfully run under Apache 1.3.33 (no Apache2 variants work). e.g.:
#!C:/Temp/情報/Perl/bin/perl.exe

This is almost acceptable but where things fall down is if the Japanese (Shift_JIS) characters contain the hex 5C byte sequence (\ in ascii). e.g.:
#!C:/Program Files/表示設定/Perl/bin/perl.exe

Under this scenario Apache still seems happy but Perl now complains with the following errors:
Premature end of script headers: c:/program files/apache group/apache2 +/cgi-bin/spatialdirect/spatialdirect.pl Can't locate strict.pm in @INC (@INC contains: .) at c:\\PROGRA~1\\APA +CHE~1\\apache2\\cgi-bin\\SPATIA~1\\SPATIA~1.PL line 40.\n BEGIN failed--compilation aborted at c:\\PROGRA~1\\APACHE~1\\apache2\\ +cgi-bin\\SPATIA~1\\SPATIA~1.PL line 40.\n

Where line 40 (referenced in the error above) is the first non-comment line in the code and contains simply:
use strict;

Commenting out this line gives the same error on the next line which is:
use LWP::UserAgent;

ie. Perl is having a lot of trouble with the un-escaped \ in the path.

Does anyone know how I can get around this?

thanks,
Nic

Replies are listed 'Best First'.
Re: shebang I18N and apache
by Tanktalus (Canon) on Feb 03, 2005 at 00:25 UTC

    Honestly? Don't use non-7-bit-ascii characters in your path. "Doc, my arm hurts when I lift it this high." "Then don't lift it that high."

    It may work for some things, but, really, is it that important what your directory structure is when compared to actually getting your CGI scripts working?

      It sure would make life easier if we could figure out a way of getting this working...

        You will be in for more hurt than is worth the effort I fear. The File::Spec module splits the path (on Win32) on \x5C. I think you will need to recompile your Perl in a way that it uses forward slashes in all its configuration parameters, and you will need to patch at least File::Spec. I've recently learned that CPANPLUS also does not use File::Spec, and I assume that there are other modules that don't use it, but still perform path manipulation, so you will possibly need to patch these as well; maybe you are lucky though and the modules performing path manipulation are unix-centric and thus think that the forward slash is the measure of all things and spaces in filenames are forbidden.

        A smallish hack might be to edit the main Config.pm of Perl and change all paths there, but I think you need to patch the Perl.exe binary as well and "fix" all paths there too.

Re: shebang I18N and apache
by Anonymous Monk on Feb 03, 2005 at 11:14 UTC
    Try using the tilde name ("Micros~1") of the Perl interpreter. dir shows it, so does the properties context window.