in reply to Overriding constructor

You want your new() method to be very simple. It basically blesses the object, then calls $self->init() which does all the real work. You parent class may have this as an abstract method (just dies; forces child to define sub init) or it could be an empty method that just returns.

All derived classes would inherit the Parent new() method and either define or inheirit init().

package Parent; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = {}; bless $self, $class; $self->init(@_); return $self; } sub init { return; # or die to force child class to do something here } package Child; use base qw(Parent); sub init { # do child specific stuff; }
For a great OOP reference, see Damian's book Object Oriented Perl.

Ivan Heffner
Sr. Software Engineer, DAS Lead
WhitePages.com, Inc.