Challenge 2: Inheritance with @ISA — Possible Solution ==================================================================== package Shape; sub area { return 0; } package Square; our @ISA = ('Shape'); sub new { my $class = shift; my $side = shift; return bless { side => $side }, $class; } sub area { my $self = shift; return $self->{side} * $self->{side}; } package main; use strict; use warnings; use feature 'say'; my $sq = Square->new(4); say $sq->area(); Output: 16 WHY THIS WORKS AS AN ANSWER ------------------------------ package Shape; with a plain sub area { return 0; } reuses the chapter's own base-class pattern with an unimplemented/default method — deliberately simple, since Square is expected to override it. our @ISA = ('Shape'); inside package Square; reuses the chapter's own inheritance declaration directly, making Square a subclass of Shape — this is what would let Square inherit Shape's area() automatically IF Square didn't define its own, exactly the chapter's own Dog-inherits- new-from-Animal point. Square's own sub new and sub area both reuse the chapter's shift-the- class-then-shift-the-args constructor pattern and the shift-self-first method pattern respectively — since Square defines its OWN area(), that version wins over Shape's inherited one, per the chapter's own explanation that "Perl searches the current package first" before walking @ISA. $self->{side} * $self->{side} reuses ordinary hash-value access (Course 1, Chapter 4) through the arrow syntax (Course 1, Chapter 9) to compute the actual square's area — Square->new(4) stores side => 4, so area() correctly computes 4 * 4 = 16.