I find what you're doing a little confusing. If you want to add methods to MP3::Napster, you can certainly do that by having a second module that also defines things in the MP3::Napster namespace. For example, if your module is in ~/lib/MyNapster.pm,
package MP3::Napster; # *not* "package MyNapster;" sub blah1 { ... sub blah2 { ... sub blah3 { ... 1;
and then in your code you would have to use both modules to make your methods available.
#!/usr/bin/perl -w use strict; use MP3::Napster; use MyNapster; my $nap = MP3::Napster->new(); $nap->blah1(); ...
But that seems, well, odd. Certainly not in the spirit of the object oriented philosphy of encapsulation. Why not just subclass MP3::Napster? (In spite of what you say, depricated, I do think that you're creating a module -- a module that inherits and relies heavily on another, but that's exactly what oop is supposed to do.) Again, if your module is at ~/lib/MyNapster.pm,
package MyNapster; @MyNapster::ISA = qw / MP3::Napster /; sub blah1 { ... sub blah2 { ... sub blah3 { ... 1;
and then, essentially use MyNapster as you would MP3::Napster, but with your enhancements.
#!/usr/bin/perl -w use strict; use MyNapster; $nap = MyNapster->new(); $nap->blah1(); ...
There are a couple perl oop/module tutorials out there including perlmod, perlmodlib, perltoot, perlobj and perlbot. You ought to consult them before writing your howto to avoid doing redundant work. But fresh, new documentation is always appreciated!
HTH, Eric
In reply to Re: How do I create a submodule transparent to its parent without modifying the parent?
by eg
in thread How do I create a submodule transparent to its parent without modifying the parent?
by deprecated
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |