{ my $a; $a = \$a; # reference count of $a increases to 1 } # $a goes out of scope, but $a stays in use because of its reference count #### my $a; $a = \$a; # reference count of $a increases to 1 undef $a; # reference count decreases to 0 } # $a goes out of scope, $a gets freed because of its reference count of 0 #### $retVal = $someObject->bar()->doSomething(); $retVal = \$retVal; #### my $myVal = $someObject->bar()->doSomething(); $retVal = \$myVal;