in reply to Re^2: $_, one lexical scope removed
in thread $_, one lexical scope removed

I was trying to make my example code as side-effect free as possible

Using $_ doesn't mean your code is side-effect free, just that the side-effects are implicit. This is the reason you should use $_ with caution. It can be a nice way to increase clarity, but as your question ably demonstrates, can often introduce much confusion.