Compiling a package into a namespace

David Cantrell david at
Fri Apr 11 20:03:30 BST 2008

On Fri, Apr 11, 2008 at 07:52:56PM +0100, Simon Wistow wrote:

> This is very possibly one of those "You're asking the wrong question" 
> questions but what the hell.

It's more a case of "you're not telling us enough" :-)

> I have a mod_perl app and I want to load a package called 'foo' defined 
> in ~/simon/a/ However I also want to load a package called 'foo' 
> defined in ~/simon/b/ 
> This will cause problems. 

Assuming that ~simon is in @INC, then ...

  use a::foo;
  use b::foo;

will load them both.  Which (ignoring the effect on %INC and any
importing) is equivalent to loading a single file that reads ...

  package foo;
  # stuff from .../a/

  package foo;
  # stuff from .../b/

which is Just Fine.  Or are you worried about, eg, both of them defining
a subroutine with the same name?

header   FROM_DAVID_CANTRELL    From =~ /david.cantrell/i
describe FROM_DAVID_CANTRELL    Message is from David Cantrell
score    FROM_DAVID_CANTRELL    15.72 # This figure from experimentation

More information about the mailing list