Subject: | Important Bug in mod_perl version detection |
Original Code:
# Turn on special checking for Doug MacEachern's modperl
my $MOD_PERL = 0;
if (exists $ENV{MOD_PERL}) {
eval "require mod_perl";
if (defined $mod_perl::VERSION) {
my $float = $mod_perl::VERSION;
$float = ~ s/^.+?([\d.]+).+$/$1/;
if ($float >= 1.99) {
$MOD_PERL = 2;
require Apache::RequestUtil;
eval "require APR::Table"; # Changing APIs? I hope not.
} else {
$MOD_PERL = 1;
require Apache;
}
}
}
Error:
root@hosting [~]# /etc/init.d/httpd configtest
Use of uninitialized value in substitution (s///) at /usr/lib/perl5/5.8.6/CGI/Cookie.pm line 29.
[Sat Mar 12 14:46:37 2005] [error] Can't locate Apache/RequestUtil.pm in @INC (@INC contains: /usr/local/rt3/local/lib /usr/local/rt3/lib /usr/lib/perl5/5.8.6/i686-linux-thread-multi /usr/lib/perl5/5.8.6 /usr/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl . /usr/local/apache/ /usr/local/apache/lib/perl) at /usr/lib/perl5/5.8.6/CGI/Cookie.pm line 32.\nCompilation failed in require at /usr/local/rt3/bin/webmux.pl line 103.\nBEGIN failed--compilation aborted at /usr/local/rt3/bin/webmux.pl line 103.\nCompilation failed in require at (eval 6) line 1.\n
Syntax error on line 1169 of /usr/local/apache/conf/httpd.conf:
Can't locate Apache/RequestUtil.pm in @INC (@INC contains: /usr/local/rt3/local/lib /usr/local/rt3/lib /usr/lib/perl5/5.8.6/i686-linux-thread-multi /usr/lib/perl5/5.8.6 /usr/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl . /usr/local/apache/ /usr/local/apache/lib/perl) at /usr/lib/perl5/5.8.6/CGI/Cookie.pm line 32.
Compilation failed in require at /usr/local/rt3/bin/webmux.pl line 103.
BEGIN failed--compilation aborted at /usr/local/rt3/bin/webmux.pl line 103.
Compilation failed in require at (eval 6) line 1.
My Solution:
Comment Line 29 /usr/lib/perl5/5.8.6/CGI/Cookie.pm
my $float = $mod_perl::VERSION;
# $float = ~ s/^.+?([\d.]+).+$/$1/; #comment by bug
if ($float >= 1.99) {
Hay put a test print under my $float = $mod_perl::VERSION; and get 1.29
Code:
my $float = $mod_perl::VERSION;
print $float; # Test: Check $float
Output:
1.29
This bug is reproduce in Perl 5.8.6 and older with CGI::Cookie v1.24 and CGI v3.0.6