I have asked this question before. However, I have made progress since last time. The basic concept is I have this module, and all its functions are written. However, I want it to return an object of another module with the functionality of my module as well. Damian Conway actually has something like this in his book, but when I use it I get funny errors. So perhaps I am doing something wrong in my module or perhaps I am doing something wrong in my code. Either way, I suspect our monks can tell me which it is.
## begin mymodule.pm package OtherModule::MyModule; use OtherModule; @OtherModule::MyModule::ISA = qw (OtherModule ); sub new { my $self = $_[0] -> SUPER::new(@_[1..$#_]); ${ $self -> ${ _count } }--; $self -> { _count } = \$_count; ${ $self -> ${ _count } }++; $self; } ### begin myscript.pl use OtherModule; use OtherModule::MyModule; our $object = OtherModule::MyModule -> new ( qw( foo bar baz bletch ) +);
the error messages I get that are pertinent are thus (where MP3::Napster is "OtherModule" and OpenNap.pm is "MyModule"):
Uncaught exception from user code: Undefined subroutine MP3::Napster::OpenNap::registry at /usr/l +ocal/libdata/perl5/site_perl/MP3/Napster/Base.pm line 29 MP3::Napster::Base::AUTOLOAD('MP3::Napster::OpenNap=HASH(0x39c +9c)', undef) called at /usr/local/libdata/perl5/site_perl/MP3/Napster +.pm line 398 MP3::Napster::disconnect('MP3::Napster::OpenNap=HASH(0x39c9c)' +) called at /usr/local/libdata/perl5/site_perl/MP3/Napster.pm line 88 MP3::Napster::new('MP3::Napster::OpenNap', '127.0.0.1:31337') +called at /home/alex/conf/lib.perl/MP3/Napster/OpenNap.pm line 76 MP3::Napster::OpenNap::new('MP3::Napster::OpenNap', '127.0.0.1 +:31337') called at skillz line 24 main::dacts() called at skillz line 127
Sorry, im sure that will be wrapped in the ugliest manner possible on most browsers. I gather I am having a problem with something called 'AUTOLOAD'? I'm just not sure how to make it happy. I get the feeling I am very close to being done here.

Thanks again, and sorry if I am repeating myself.

brother dep.

--
Laziness, Impatience, Hubris, and Generosity.


In reply to Reverse Inheritance Irritance by deprecated

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.