Hi, On Mon, 20 Sep 2004, Kevin Scaldeferri wrote:
> The current version of Devel::Cover asserts that running it on a > mod_perl server ought to be as simple as adding 'use Devel::Cover' to > your startup script. However, when I do this, I get the following > failure: > > Syntax error on line 1225 of /home/kevin/.../conf/httpd.conf: > Can't use an undefined value as a HASH reference at > /home/kevin/lib/perl5/site_perl/5.8.0/i686-linux-64int/Devel/Cover.pm > line 310. > > BEGIN failed--compilation aborted at /home/kevin/.../conf/startup.pl > line 7. > > > Any help would be appreciated. I use the patch listed below. It fixes this bug and also sets permission 0777 to a cover_db directory as it is created when apache runs as root, so when it changes it's UID it can write to this directory. P.S. And don't forget to use -X switch when starting httpd. Vadim. diff -ur Devel-Cover-0.47.orig/lib/Devel/Cover.pm Devel-Cover-0.47/lib/Devel/Cover.pm --- Devel-Cover-0.47.orig/lib/Devel/Cover.pm 2004-08-27 17:08:09.000000000 +0400 +++ Devel-Cover-0.47/lib/Devel/Cover.pm 2004-09-21 13:52:12.000000000 +0400 @@ -30,6 +30,7 @@ # use Carp; $SIG{__DIE__} = \&Carp::confess; my $Initialised; # import() has been called. +my $Checked = 0; my $Dir; # Directory in which coverage will be # collected. @@ -170,6 +171,7 @@ sub import { + return if $Checked++; my $class = shift; my @o = (@_, split ",", $ENV{DEVEL_COVER_OPTIONS} || ""); @@ -211,7 +213,10 @@ $Dir = $1 if Cwd::getcwd() =~ /(.*)/; } - mkdir $DB unless -d $DB; # Nasty hack to keep 5.6.1 happy. + unless(-d $DB){ # Nasty hack to keep 5.6.1 happy. + mkdir $DB; + chmod 0777, $DB; + } $DB = $1 if Cwd::abs_path($DB) =~ /(.*)/; Devel::Cover::DB->delete($DB) unless $Merge; @@ -240,6 +245,7 @@ if ($ENV{MOD_PERL}) { + eval 'BEGIN{1}'; check(); set_first_init_and_end(); }