Workaround for cygwin perl 5.10 CGI

Alles, was Perl betrifft, kann hier besprochen werden.

Workaround for cygwin perl 5.10 CGI

Postby n8v » 08. April 2008 22:52

I've got Cygwin Perl 5.10.0 (experimental) installed, not the XAMPP perl add-on.

My CGI was failing because it couldn't find any of the perl libs. The apache error log said things like:

Code: Select all
[Tue Apr 08 12:27:41 2008] [error] [client] Premature end of script headers:
[Tue Apr 08 12:27:41 2008] [error] [client] Can't locate in @INC (@INC contains: /usr/lib/perl5/5.10/i686-cygwin /usr/lib/perl5/5.10 /usr/lib/perl5/site_perl/5.10/i686-cygwin /usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10/i686-cygwin /usr/lib/perl5/vendor_perl/5.10 /usr/lib/perl5/vendor_perl/5.10 /usr/lib/perl5/site_perl/5.8 .) at C:/xampp/cgi-bin/ line 5.
[Tue Apr 08 12:27:41 2008] [error] [client] BEGIN failed--compilation aborted at C:/xampp/cgi-bin/ line 5.

I found out that the @INC locations compiled into my perl all begin with /usr/lib, which is secretly some sort of magical link to c:/cygwin/lib instead of c:/cygwin/usr/lib.

Code: Select all
$ ls -1t /usr/lib|wc -l

$ ls c:/cygwin/usr/lib
[no files -- it's an empty directory]

Perl works fine from the cygwin shell but is borken when initiated by Apache.

So I wrote a script to convert the @INC to the appropriate windowsish paths for my shebang line:
Code: Select all
$ perl -e 'print join " ", map {s~/usr/lib~c:/cygwin/lib~;"-I$_"} @INC'
-Ic:/cygwin/lib/perl5/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/5.10 -Ic:/cygwin/lib/perl5/site_perl/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/site_perl/5.10 -Ic:/cygwin/lib/perl5/vendor_perl/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/vendor_perl/5.10 -Ic:/cygwin/lib/perl5/vendor_perl/5.10 -Ic:/cygwin/lib/perl5/site_perl/5.8 -I.

Now my shebang line is long but the CGI script works.

Code: Select all
#!C:/cygwin/bin/perl -Ic:/cygwin/lib/perl5/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/5.10 -Ic:/cygwin/lib/perl5/site_perl/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/site_perl/5.10 -Ic:/cygwin/lib/perl5/vendor_perl/5.10/i686-cygwin -Ic:/cygwin/lib/perl5/vendor_perl/5.10 -Ic:/cygwin/lib/perl5/vendor_perl/5.10 -Ic:/cygwin/lib/perl5/site_perl/5.8 -I.

use strict;
use warnings;
use File::Slurp;
use Text::Markdown 'markdown';
use File::Find;
use Data::Dumper;

Posts: 1
Joined: 08. April 2008 22:29

Return to Perl

Who is online

Users browsing this forum: No registered users and 2 guests