pike_uk has asked for the wisdom of the Perl Monks concerning the following question:
## how does this happen? I thought that assigning $testob to a string or calling undef would remove any reference to the memory location of the object, but it is clear here that $blah in the "object" retains this as does $testob?? please enlighten me! thanks in advance.## the test script use Report::testob; my $testo; $x=0; while($x<10){ undef $testo; $testo="ooof"; $testo=testob->new(); $testo->printblah(); $testo="yess"; $x++; } ##### # the "object" package testob; sub new { my $class=shift; my $self={@_}; bless($self,$class); return $self; } sub printblah{ my $self=shift; $blah++; $self->{blah}++; print "blah is $blah \n"; print "self blah is ".$self->{blah}."\n"; } 1; ##### # the output blah is 1 self blah is 1 blah is 2 self blah is 1 blah is 3 self blah is 1 blah is 4 self blah is 1 blah is 5 self blah is 1 blah is 6 self blah is 1 blah is 7 self blah is 1 blah is 8 self blah is 1 blah is 9 self blah is 1 blah is 10 self blah is 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undef doesnt work?This has got me stumped
by broquaint (Abbot) on Feb 09, 2004 at 10:20 UTC | |
by pike_uk (Initiate) on Feb 09, 2004 at 10:29 UTC | |
by broquaint (Abbot) on Feb 09, 2004 at 10:35 UTC | |
|
Re: Undef doesnt work?This has got me stumped
by borisz (Canon) on Feb 09, 2004 at 10:19 UTC | |
|
Re: Undef doesnt work?This has got me stumped
by Corion (Patriarch) on Feb 09, 2004 at 10:22 UTC |