Hello,
After finding out that my classes using Class::Std did not work with mod_perl I was delighted to find out that Object::InsideOut solved my problem.
However I have come across a different problem which did not occur when using Class::Std: I get an error when loading classes which use the Singleton pattern:
package MyClass;{
use Object::InsideOut;
my $instance;
sub _init :INIT{
my ($self, $arg_ref) = @_;
$instance = $self;
}
sub instance(){
if (defined $instance){
return $instance;
} else {
return new(@_); # error occurs on this line
}
}
}
The error is 'Undefined subroutine &MyClass::new' which seems to imply that the 'new' subroutine is not yet defined at the time that my 'instance' subroutine gets defined. The error does occurr in a consistent manner which makes it even harder to troubleshoot, if I change the order in which my objects are instanciated it can 'solve' the problem but obviously I need to find the root cause the erradicate it completely. I have tried using the CPAN module Class::Singleton instead of my own implementation but I get the same error. I do not get the error when running the app outside of the mod_perl environment but again that could just be a coincidence as the error is not occurring consistently...
Any ideas? Is it OK in theory to call 'MyClass->new' from within MyClass?
Many thanks
Steph