anything outside of the if {} will not see or be affected by the assignment of $test. but anything within sub main {} will be able to see $blah because it has been globally instantiated. Hope that helps.sub main { my $blah; if ($blah =~/(\d+)\s{2}/) { my $test = $1; } }
In reply to A Simple Explanation of scoping
by tradez
in thread where to declare a variable...
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |