Subclassing Just Works™
Old Skool
package Your::Point2; use base 'Your::Point'; our $X = 42; our $Y = 69;
New Skool
package Your::Point2; use Badger::Class base => 'Your::Point', vars => { X => 42, Y => 69, };
In Use
print Your::Point->new->x; # 0 print Your::Point2->new->x; # 42
Thus Spake Andy:
We can now subclass our point module, either using "classic" Old Skool
Perl style, or using the equivalent Badger::Class
syntactic sugar.
Our subclass can define it's own $X
and $Y
package variables which
will be used as the defaults when x
and y
aren't specified as configuration
parameters.