in reply to Re^2: Variable scope
in thread Variable scope
Oh, and another use for state variables — caching/memoization. For example:
I'm sure there are plenty more uses.sub sort_network { state @mem; my $cmp = $mem[@_] //= do { ... }; my @res = @_[ @$cmp ]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Variable scope
by choroba (Cardinal) on Apr 06, 2018 at 09:42 UTC | |
by Anonymous Monk on Apr 06, 2018 at 10:33 UTC | |
by choroba (Cardinal) on Apr 06, 2018 at 10:56 UTC |