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


In reply to seamlessly use an extended class's use'd libs by Anonymous Monk

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.