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 ]; }
In reply to Re^3: Variable scope
by Anonymous Monk
in thread Variable scope
by Alphaphi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |