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/factory.pm line 4.

with respect -shoez

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


In reply to problem using Class::Factory by shoez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.