This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
mod_perl Subject: Re: Module Function Name Issue From: Ken Williams <ken@forum.swarthmore.edu> Date: Sun, 27 Aug 2000 12:10:28 -0500 philip@datafoundry.net (Philip Molter) wrote: >I have a module with some code like this: > > package Object; > sub new { > my $class = shift; > return bless {}, $class; > } > > sub SubObj { > Object::SubObj->new(); > } > > 1; > > package Object::SubObj; > sub new { > my $class = shift; > return bless {}, $class; > } This problm isn't atually directly related to mod_perl, it only happens there because the Perl uses various heuristics to decide whether the ambiguous notation Blah::Arf->subr means Blah::Arf()->subr() or 'Blah::Arf'->subr(). In the first case it calls the Arf package in the Blah package, which returns a blessed object, and then it calls that rturned object's subr() method. In the second case, it calls the subr() method of the Blah::Arf class. I prefer to treat this ambiguous notation as a black box - Perl may choose one way or the other, but I don't care to figure out what its rules are. The rules might be complicated or stupid, or they might be intuitive and smart, but I prefer to steer clear of the whole situation. In your case, something about the loading order & code persistence under mod_perl is reversing the sense of the ambiguity. You can either try to figure out why that's happening, or avoid the issue altogether. To disambiguate, you can use the workaround you've already found, or use the compile-time mechanism given by newer Perls (5.005+): Object::SubObj::->new(); ===