BarMeister has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to auto-export a routine from a module I wrote under mod_perl. I keep getting warning messages saying that the subroutine is being redefined. Is there some special way that you are supposed to export routines in mod_perl to avoid this?

The module only contains one routine so I do an auto-export. Here is how I do the export:

package ATG::Constants; use strict; use warnings; use base qw(Exporter); our @EXPORT = qw(const); sub const { #code goes here }

Every other module that needs this routine I say use ATG::Constants.

Am I doing something wrong here? Since I am getting this warning I would assume that I am.

Thanks for any help.

Replies are listed 'Best First'.
Re: exporting subroutine in mod_perl
by perrin (Chancellor) on Mar 30, 2006 at 16:12 UTC
    Are you using something like Apache::Reload or Apache::Registry that might reload the scripts you use it from?
      Yes, I am using Apache::Registry
        That will reload your code if you modify the file, calling the export again. There's more more information in the mod_perl docs.