No need to really even do that. Use references and have DoIt return the reference:
That prevents the reference count from being decremented and hence no gc (well at least tell the end of the block containing $h)my $h = DoIt( $max ); sub DoIt{ my $limit=shift; my $i; my $myhash; foreach $i (0..$limit){ $myhash->{$i}=1; } $func_done = (times)[0]; $myhash; }
In reply to Re^4: Garbage collection at subroutine return
by derby
in thread Garbage collection at subroutine return
by tcarmeli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |