use v5.14; sub get_counter { my ($count) = @_; my $closure = sub { $count++ }; return $closure; } my $counter = get_counter(40); my $other = get_counter(99); say $counter->(); say $other->(); say $counter->(); say $other->(); say $counter->();