Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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"

In reply to problem using Class::Factory by shoez

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2021-06-18 03:20 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (87 votes). Check out past polls.