The code above is stripped down to an example. I do find this behaviour quite suprising and very NWIM. I would go so far to say that it's documentated incorrectly (at the very least, poorly). Both are described as dynamic scoping.
Looking at perlsub and local() This is known as dynamic scoping. Lexical scoping is ...