in reply to Re^2: Using an "outer" lexical in a sub?
in thread Using an "outer" lexical in a sub?

{ my $n = 10; $ref1 = sub { print( $n++, "\n" ) }; $ref2 = sub { print( $n++, "\n" ) }; }
When the anonymous subroutine that is stored in $ref1 is created it increases the reference count for that instance of $n to 2.

When the anonymous subroutine that is stored in $ref2 is created it increases the reference count for that instance of $n to 3.

The two anonymous subroutines share the same $n in this case.