I've a boot function:

static void mpxs_Apache__Scoreboard_BOOT(pTHX)
{
     HV *stash;
...
     stash = gv_stashpv("Apache::Scoreboard", TRUE);
     newCONSTSUB(stash, "REMOTE_SCOREBOARD_TYPE",
                 newSVpv(REMOTE_SCOREBOARD_TYPE, 0));
}

then I've a code using Apache::Scoreboard::REMOTE_SCOREBOARD_TYPE in 
Scoreboard_pm, which becomes Scoreboard.pm in WrapXS. The problem is 
that perl cannot see this constant and complains about

Bareword "Apache::Scoreboard::REMOTE_SCOREBOARD_TYPE" not allowed while 
"strict subs" in use at 
/home/stas/apache.org/mp-sb/blib/lib/Apache/Scoreboard.pm line 48.

Obviously the module is not loaded at compile time, so the constant is 
not available.

The solution is to wrap the XS loading in the BEGIN block:

BEGIN {
     use Apache::XSLoader ();
     our $VERSION = '0.01';
     Apache::XSLoader::load __PACKAGE__;
}

but I've no control over this part since it's autogenerated. Should we 
change the code generator to always put the loading part in the BEGIN 
block. It won't hurt other modules and solve my problem.

Index: lib/ModPerl/WrapXS.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/WrapXS.pm,v
retrieving revision 1.39
diff -u -r1.39 WrapXS.pm
--- lib/ModPerl/WrapXS.pm       14 Dec 2001 05:12:13 -0000      1.39
+++ lib/ModPerl/WrapXS.pm       13 Mar 2002 16:45:10 -0000
@@ -496,10 +496,13 @@
  $noedit_warning

  package $module;
-$isa
-use $loader ();
-our \$VERSION = '0.01';
-$loader\::load __PACKAGE__;
+
+BEGIN {
+    $isa
+    use $loader ();
+    our \$VERSION = '0.01';
+    $loader\::load __PACKAGE__;
+}

  $code



_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to