in reply to Re^4: Scope, package, and 'my' variables
in thread Scope, package, and 'my' variables
The issue is that the assignment of $var within the block under bbb never happens before you call do_b. Don't think of a line like my $x = somevalue; as a declaration of a variable to be initialized before the program begins. Think of it as a statement that runs when the program gets to it.