in reply to Re^2: Garbage collection at subroutine return
in thread Garbage collection at subroutine return
You don't need to have it global, just have it scoped outside the sub.
For example:
Of course, I haven't tried this, but I think it'd do what you want, and handle the case where it's called twice with different values of $limit.{ my %myhash; sub DoIt{ my $limit=shift; my $i; # really, what you'd do here is just init the # as-yet uninitialized part foreach $i ((scalar keys %myhash)..$limit){ $myhash{$i}=1; } $func_done = (times)[0]; return; } } # scope for %myHash
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Garbage collection at subroutine return
by derby (Abbot) on Feb 15, 2007 at 17:26 UTC | |
by RMGir (Prior) on Feb 16, 2007 at 15:06 UTC |