#!/usr/bin/perl use Devel::Peek; { package Foo; sub new { my $class = shift; my $val = shift; return bless { thing=>$val }; } sub val { my $self = shift; return "val: " . (++$self->{theVal}); } sub DESTROY { print "destroyed at ", ${shift}->{theVal}, "\n"; } } my $b = [ ]; print "--- before building t ---\n"; Dump($b); my $t = Foo->new($b); print "--- after building t ---\n"; Dump($b); print "--- printing 1 ---\n"; print $t->val(), Dump($b), undef($t), "--- printing 2---\n", Dump($b), ".\n"; print "--- after print ---\n"; Dump($b);