in reply to OO Perl: calling a constructor within a class
I differ in my tastes from davorg. Instead I, like
merlyn, prefer to keep instance and class methods
separate. His opinion is stated more strongly
than mine would be, but I would still make new your basic
constructor, give your complex constructor from an existing
object a more descriptive name, then just call new from
within the more complex constructor. Something like this
silly little example:
sub copy { my $self = shift; my $copy = ref($self)->new(%$self, @_); # Do stuff return $copy; } sub new { my $class = shift; return bless ({ NAME => '', USERNAME => '', # etc @_ # allows overriding defaults in the constructor :-) }, $class); }
In Section
Seekers of Perl Wisdom