X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlobj.pod;h=891ebe37f257111eb1ce52acacea377d4633ff86;hb=2810d90162dc487ea10933114344f32d14b3d619;hp=7d7beaf477d6e04189109043f7bdaf89bea1f672;hpb=2359510ddb135dcc6e80153f51cff0a97b20b597;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlobj.pod b/pod/perlobj.pod index 7d7beaf..891ebe3 100644 --- a/pod/perlobj.pod +++ b/pod/perlobj.pod @@ -97,9 +97,11 @@ so that your constructors may be inherited: } Or if you expect people to call not just C<< CLASS->new() >> but also -C<< $obj->new() >>, then use something like this. The initialize() -method used will be of whatever $class we blessed the -object into: +C<< $obj->new() >>, then use something like the following. (Note that using +this to call new() on an instance does not automatically perform any +copying. If you want a shallow or deep copy of an object, you'll have to +specifically allow for that.) The initialize() method used will be of +whatever $class we blessed the object into: sub new { my $this = shift; @@ -485,9 +487,8 @@ if you don't care to leak. For example, here's a self-referential node such as one might use in a sophisticated tree structure: sub new_node { - my $self = shift; - my $class = ref($self) || $self; - my $node = {}; + my $class = shift; + my $node = {}; $node->{LEFT} = $node->{RIGHT} = $node; $node->{DATA} = [ @_ ]; return bless $node => $class;