http://www.perlmonks.org?node_id=176148


in reply to sub and anonymous sub

I'll give you a scarier one:
sub my_sub { local $my_sub_level = $my_sub_level + 1; .. }
Yes, the localization for the variable doesn't happen until the end of the statement, so the value on the right is the previous value (plus one), and it's undone at the end of the block.

-- Randal L. Schwartz, Perl hacker