I know this topic has been discussed to death, but I think I can add
something new.  :-)

Upon using Apache::RegistryLoader, I noticed my error logs started
filling up with the dreaded "subroutine redefined" error.  These errors
occur at the moment my scripts scripts are preloaded using
Apache::RegistryLoader.

I put together a minimalistic example to demonstrate the problem.
Consider the following module where function "foo" is exported by
default and "bar" is exported on request.

###############################

package Foo;

use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Exporter ();

@ISA = ('Exporter');
@EXPORT = qw(foo);
@EXPORT_OK = qw(bar);

sub foo {
  return "foo";
}

sub bar {
  return "bar";
}

1;

###############################

And consider the following script served by Apache::Registry:

###############################

#!/usr/bin/perl -w

use strict;
use CGI ();
use Foo ();  # works okay, no error
#use Foo;  # causes "Subroutine foo redefined..." error
#use Foo qw(bar);  # causes "Subroutine bar redefined..." error
#use Foo qw(:DEFAULT bar);  # causes errors for both foo and bar

my $q = CGI->new();
print $q->header();
print "Hello World\n";

###############################

I tried the above script while "use"-ing Foo using the above techniques
(stopping and starting the server each time to retest
Apache::RegistryLoader.)  Upon each server start, RegistryLoader kicked
out the error(s) shown commented above.  So it seems to be the import
process causing the error.

In all cases, the Apache::Registry script works fine.  The error only
appears when the script is preloaded using Apache::RegistryLoader -- I
can suppress the error by not using RegistryLoader.

So what's causing the error?  Why is the subroutine being redefined?

Thanks,
Matt

apache 1.3.6
mod_perl 1.21
perl 5.00503
Apache::Registry 2.01
Apache::RegistryLoader 1.90

Reply via email to