You are using package variables (what other languages call static) and in your update you have the right syntax. If you had an object, the way to access its parent's package variable is stated in perlobj, at the place you quoted it: for a static method: $self->SUPER::save(); and for a package variable %{$self->SUPER::cfg};

But package variables are not "object variables" or member variables (?whatever?). It would be better to store %cfg into $self's hash for at least one reason: inheritance is taken care by Perl for free. Whereas in your case, Perl takes care of the inheritance of Class1 into Class2 and YOU MUST (not forget to) take care of the inheritance of Class1's package variables. That's a lot of boiler work (for me ;) ).

related: https://stackoverflow.com/questions/3109672/how-to-make-a-hash-available-in-another-module and Perl Inheritance & module variables . The latter in particular is similar to what you have shown.


In reply to Re^3: Inheritable configuration options.... but with default values? by bliako
in thread Inheritable configuration options.... but with default values? by Amblikai

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.