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

Hello all, I've got a bit of a strange error that keeps popping up, involving the subclassing of various packages. I was reading this response by the venerable Ovid pretty recently, in which he explains the an OO concept called a factory. Anyway, great idea :) So I went off to CPAN to see if there was already a module built, and low and behold Class::Factory pops up. I've been struggling to get it working however. I'm wondering if anyone could spare a few minutes to point out my problem.
In one package, the central one, I have this code..

package pkg1; use strict; use factory; etc, etc...

In the package called factory, I have the following.

package factory; use strict; use base qw(Class::Factory); __PACKAGE__->add_factory_type(hello=>'speak::hello'); 1;

Now that all seems fine to me. The package speak::hello should be preloaded using require, by Class::Factory, and I should be able to call it at a later time. Herein lies my issue. I hacked together a little test script, which contained just these lines.

#!d:/perl use lib 'c:/perlcode'; use pkg1;

Sadly it didn't work, as Perl seemingly wanted to give me the error you see below. I must be doing something hideously wrong, but I can't seem to work out what/why. Please help, I'm tearing my hair out :) Oh, and I don't know if it's worth mentioning, but I'm using the latest ActiveState Perl distribution (5.8).

Can't locate object method "add_factory_type" via package "factory" at d:/site/ line 4.

with respect -shoez

2003-04-20 edit ybiC: retitle from "strange error when subclassing packages"