A brief detour: Closures

sub make_closure {
  my $count = 1;
  return sub { $count++ };
}

my $seq_a = make_closure();
my $seq_b = make_closure();

print &$seq_a, "\n";
print &$seq_a, "\n";
print &$seq_b, "\n";
print &$seq_a, "\n";
1
2
1
3