in reply to new() function: incorrect?
You may find the replies to confusion about blessing inside a constructor interesting.
Bottom line: $class = ref($proto) || $proto; treats new as both a constructor and as a cloner. Better to have a separate clone method if you need one and simply:
sub new { my ($class, %options) = @_; # validate options return bless \%options, $class; }
which makes new a class method called by:
my $obj = Bob::MyObject->new (option => 1, );
but not as:
my $newObj = $obj->new (option => 1, );
|
|---|