note
tobyink
<p>Not an especially useful technique for managing inside-out objects. (Not without some care anyway.) Reference addresses can be recycled.</p>
<c>
use strict;
use warnings;
use Scalar::Util 'refaddr';
use Data::Dumper;
for my $i (0..2)
{
my $hash = [$i];
printf "The hash has refaddr %08X, and contents are...\n", refaddr($hash);
print Data::Dumper->Dump([$hash], ['$hash']);
}
</c>
<p>With carefully written CLONE and DESTROY methods, using the refaddr as a hash key can be made to work, but something like [mod://Hash::FieldHash] saves a lot of work.</p>
<div class="pmsig"><div class="pmsig-757127">
<small><small><tt>use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name</tt></small></small>
</div></div>
1060446
1060454