Content deleted Content added
closures in perl |
No edit summary |
||
Line 8:
sub counter {
my $x = shift;
return sub { print "$x\n"; $x--; };
}
Line 15 ⟶ 14:
$g = counter(7);
&$h(); # gives
&$h(); # gives 3
&$g(); # gives 7
|