"be consistent" | |
PerlMonks |
Perl variable garbage collectionby chinaxing (Acolyte) |
on Jul 31, 2013 at 07:16 UTC ( [id://1047188]=perlquestion: print w/replies, xml ) | Need Help?? |
chinaxing has asked for the wisdom of the Perl Monks concerning the following question: I have a little confuse about the variable garbage collection in perl in following example :
In above code, if I remove the $w_w_w, then because of the AnyEvent->io create a object, its reference become zero, then it will be reclaimed by perl, which make the code not work ( the cb will not be called );
then I assign it to scalar $w_w_w, but I dose not need the $w_w_w in the callback. but the following code not working(callback will not be called):
so I add one line code in the callback(just you can see it in the front of this requestion) : because the assertion will always be false, so it will not ran, I think the perl compiler/interpreter will optimize this line code ( drop it ), then the $w_w_w 's reference count will be zero. and the callback will not be called also. but it works. so I hope someone can explain this .(the following is a dump of perl -ODeparse
Back to
Seekers of Perl Wisdom
|
|