in reply to Extending a class

You are missing a constructor (sub MyPackage::new), search for "sub new" in Modern Perl or "sub new"

You can squat/monkeypatch like  sub SVG::Element::Foo { ... } which can work well for one-offs/scripts... and oftentimes is the only reasonable way to extend some classes

Replies are listed 'Best First'.
Re^2: Extending a class
by betacentauri (Sexton) on Apr 13, 2016 at 16:08 UTC

    Thank you for your reply! However, isn't SVG::new() already in place anyway? The MyPackage object builds and yields a MyPackage-blessed object as revealed by Data::Dumper.

    I'm checking the book by the way!

      However, isn't SVG::new() already in place anyway? The MyPackage object builds and yields a MyPackage-blessed object as revealed by Data::Dumper.

      :) ok, if the constructor is creating a MyPackage, then which code is creating a SVG::Element?

      Think a bout it

        $self->group(...) in Bar() does. I was expecting the group() method to be inherited by MyPackage and the SVG:: class blessing of the resulting object to be overridden by MyPackage:: class... but that was too much of an expectation as it turns out to be. Still have to know if it's Perl's quirky OO-system or my plain OO-ignorance.