in reply to idea for an static variable
Perl6 has a similar thing to C-style static vars. Except they're declared with the state declarator. In the following code the variable $x will maintain its value across successive invocations of the subroutine and is only visible within the subroutine:
sub foo { state $x = 1; say $x++; } foo; # outputs 1 foo; # 2 foo; # 3
Perl6 is full of all sorts of interesting declarators. See http://dev.perl.org/perl6/doc/design/syn/S03.html#Declarators
|
|---|