in reply to Point me in the right direction with OO inheritance and static variables

In the plain OO approach, just specify the default attributes in the constructor:
sub new { my $class = shift; my %params = ( name => 'John', surname => 'Doe', ); my %args = (%params, @_); # Overwrite the defaults bless \%args, $class }

To call the constructor of the parent class, use SUPER:

sub new { my $class = shift; my $self = $class->SUPER::new(%args); return $self }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Point me in the right direction with OO inheritance and static variables
by Amblikai (Scribe) on Sep 02, 2014 at 10:11 UTC

    Thanks! How does the child object "know" which class is the parent? (I hope my terminology is correct)

    In other words, when i'm creating an object in the class which is inheriting the attributes, how does it know where SUPER points?

    Thanks again for your help!

      In the child class, you specified
      use parent 'Parent::Class';

      right? See parent.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      The child class has a package variable called @ISA which tells it the parent class. This is an array because multiple inheritance is supported.

      package Child { require Parent; our @ISA = "Parent"; }

      For some reason, setting @ISA directly like that is not very fashionable, and a lot of people prefer to use a module like base, parent, or superclass to do so. Using one of those modules ensures that @ISA gets set at compile-time rather than run-time, though in practice this feature of them is almost never important.