The problem is that
->new() is a method that is exported by Object::InsideOut, and in the case of runtime loading, is something not available when the parser carries on to your
instance() subroutine.
As ->new() is a method, the error can be avoided by invoking it that way:
sub instance
{
if (defined $instance) {
return $instance;
} else {
my $class = shift; # Extract class from args
return $class->new(@_); # Invoke ->new() method
}
}