http://www.perlmonks.org?node_id=62785


in reply to Re: XML::Parser Tutorial
in thread XML::Parser Tutorial

Why do you want to subclass it? It works much better as a "has-a" than an "is-a", unless you want to get very cozy from the base class implementation, which is a maze of twisty tiny packages all alike.

Just delegate the methods that you want to provide in your interface, and handle the rest. Make a hash with one of the elements being your "inherited" parser. I believe it's called the "wrapper" pattern, but I don't name my patterns—I just use them!

-- Randal L. Schwartz, Perl hacker