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
In reply to Re: Variable scoping outside subs
by Zaxo
in thread Variable scoping outside subs
by xiper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |