in reply to Re^2: static storage in a local subroutine?
in thread static storage in a local subroutine?
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
|
|---|