deprecated has asked for the wisdom of the Perl Monks concerning the following question:
MP3::Napster::MessageCodes.pm looks like this:# MP3::Napster, by Lincoln Stein package MP3::Napster; use MP3::Napster::MessageCodes; sub new { my $class = shift; # create and store the server object if (my $servobj = MP3::Napster::Server->new($server,$self,$metaserve +r)) { $self->server($servobj); } else { $self->disconnect; return; } $self->install_default_callbacks; $self; }
What I would like to do is create a new module, MP3::Napster::OpennapMessageCodes.pm and another new module, MP3::Napster::Opennap. I have created a new 20-25 methods to add to the MP3::Napster.pm module, but they should be contained in another module. I have also created a new hash with message codes as they appear in the opennap source. How do I make these two modules part of the parent module without the parent module specifying them? In other words, how can I distribute a module that will make available methods to an object created from its parent module without the parent module having to be modified?package MP3::Napster::MessageCodes; require Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter MP3::Napster::Base); @EXPORT = qw(JOIN_ACK MOTD TIMEOUT TRANSFER ABORTED); 1;
My second question is can I create a new MessageCodes module that will contain values in @EXPORT that are also in the "stock" MessageCodes module? Im pretty sure I can since theyre in a hash.
Thanks again, everyone. I think I will be writing a small module-howto when I get this whole thing done. By the way, I have Damian Conway's book. However, I am kind of at a loss on where and how to start with this. His book takes things from the perspective of creating a module, and thats not strictly what I am doing here.
dep.
--
i am not cool enough to have a signature.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I create a submodule transparent to its parent without modifying the parent?
by eg (Friar) on Jan 28, 2001 at 23:31 UTC | |
|
(tye)Re: How do I create a submodule transparent to its parent without modifying the parent?
by tye (Sage) on Jan 29, 2001 at 07:26 UTC | |
by deprecated (Priest) on Jan 30, 2001 at 04:06 UTC | |
by tye (Sage) on Jan 30, 2001 at 04:24 UTC | |
|
Re (tilly) 1: How do I create a submodule transparent to its parent without modifying the parent?
by tilly (Archbishop) on Jan 29, 2001 at 02:53 UTC |