Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Yo!
Say I have a base class, which I want another class to extend.
In that base class, I'd like to propagate a use'd lib into the class which is extending it... how would I do this?
Sorry, for some reason I"m really having a tough time figuring out how to word this to make sense...
Here's a really terse example which will hopefully make things clearer:
package Base; #use base qw( Carp ); # don't want to do that... use Carp; sub new { # do stuff, blah - you know the routine } package Foo; use base qw( Base ); # ... no good, don't wanna do '$self->carp' #sub some_method { my $self = shift; $self->carp("died") } # would rather just call it normaly, as if it were # use'd directly from within this package: sub some_method { my $self = shift; carp "died" }
Thanks!
Also, while I'm here - one other oop perl thing that's had me stumped for awhile.
So, I'm use'ing a really long-ass class path:
#!/usr/bin/perl use strict; use MyLibs::ForSome::Particular::Thing; # ugh! #my $fubar = MyLibs::ForSome::Particular::Thing->new() # how about: my $fubar = Thing->new(); # ???
Is it convieniently possible to do such a thing? It's a pet peeve of mine.
Beers!
Corey
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: seamlessly use an extended class's use'd libs
by BrowserUk (Patriarch) on Sep 09, 2002 at 04:53 UTC | |
|
Re: seamlessly use an extended class's use'd libs
by jkahn (Friar) on Sep 09, 2002 at 04:57 UTC | |
|
Re: seamlessly use an extended class's use'd libs
by rir (Vicar) on Sep 09, 2002 at 05:41 UTC | |
|
Re: seamlessly use an extended class's use'd libs
by Zaxo (Archbishop) on Sep 09, 2002 at 06:18 UTC |