This example helped me understand a lot better.sub make_counter { my $start = shift; return sub { $start++ } } my $from_ten = make_counter(10); my $from_three = make_counter(3); print $from_ten->(); # 10 print $from_ten->(); # 11 print $from_three->(); # 3 print $from_ten->(); # 12 print $from_three->(); # 4
In reply to Re^3: static storage in a local subroutine?
by tphyahoo
in thread static storage in a local subroutine?
by Moron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |