in reply to Re^4: Scope, package, and 'my' variables
in thread Scope, package, and 'my' variables

It does declare a new lexical $var over which do_b closes. However, you call the subroutine before the assignment occurs.