{
my $secret_val = 0;
sub gimme_another {
return ++$secret_val;
}
}
$secret_val now becomes unreachable by the outside world, but retains its value between calls to gimme_another.
This works fine, since $secret_val goes out of scope, but is not garbage-collected since it's still being referenced.
Last updated on 2006-08-02 14:00:00 -0800, by Shalom CraimerBack to Tech Journal