in reply to Variable scoping outside subs
You exit before line 6 is reached - it is executed at runtime. You will get the behavior I think you expect by rearranging,
The extra braces are just to limit the scope of $var further. Search closure here for much more.use strict; { my $var = 1; sub test { print "var was '$var'\n"; $var++; print "var is now '$var'\n"; } } test(); exit 0;
After Compline,
Zaxo
|
|---|