- or download this
{
my $closure;
sub x1 { $closure = shift if @_; $closure }
}
- or download this
sub x1 { state $closure; $closure = shift if @_; $closure }
- or download this
sub x1 { state $closure ... }
sub x2 { state $closure ... }
- or download this
$ perl -le 'sub x { our $c = shift if @_; $c } $::c = 1; print for x()
+, x(2)'
1
2