I would suggest starting like this:

my $LoggerClass = $self->logger_class();
This gives you lots of flexibility. Then, you have the best of both worlds: you can define a convention, and, in true perl fashion, you can define how to do something different from convention. For example, someone may want a bunch of apps to share the same logger class, so they just override logger_class, and you continue unconcerned about the change. Your default could even do much what you are doing already (although you're using @_isa_parts and $_isa_parts - two entirely different variables...):
sub logger_class { ref(shift) . '::Debug'; }
This also gives you some more flexibility where you can return an object instead of a class, or you can change the default in some other way. Or you can require the desired class to ensure it's loaded, ... whatever. It's localised. Though, if you want that extra flexibility, I'd suggest allowing the logger class to be passed in and possibly cached.

sub logger_class { my $self = shift; my $set = 0; # was a (new?) class passed in? $self->{__PACKAGE__ . ':logger_class'} = shift and $set++ if @_; # if we don't have one, construct the default. unless (exists $self->{__PACKAGE__ . ':logger_class'}) { $self->{__PACKAGE__ . ':logger_class'} = ref(shift) . '::Debug'; $set++; } # if it changed, do any configuration needed. if ($set) { # load the class, etc. } # done - return it. $self->{__PACKAGE__ . ':logger_class'}; }
This would then allow the constructor to an object set its own logger class on an object-by-object basis. Or allow a package to set its logger class by overriding and passing in the new value (to allow the initialisation to occur):
# in some other package... sub logger_class { my $self = shift; $self->SUPER::logger_class('Some::Shared::Package::Debug'); }
Lots of alternatives. Depends on how overboard you wanna go with this newfandangled "OO" fad ;-)


In reply to Re: Getting parent class data by Tanktalus
in thread Getting parent class data by nmerriweather

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.