##
sub foo {
my $x= $_[0] if ! defined $x;
print "(@_):", ++$x, " ";
undef $x if @_ && shift;
}
foo($_) for( 0,0,5,4,3,0,5,0,4,0,3 );
print $/, $x= 10, $/;
foo($_) for( 0,0,5,4,3,0,5,0,4,0,3 );
print $/;
##
##
(0):1 (0):1 (5):6 (4):5 (3):4 (0):1 (5):6 (0):1 (4):5 (0):1 (3):4
10
(0):1 (0):2 (5):3 (4):1 (3):1 (0):1 (5):2 (0):1 (4):2 (0):1 (3):2