Thanks. But that's what I don't get. Here's my confusion. I never realized that a simple loop like this (an even simpler illustration this time) ...
for (my $i=0; $i <=1; $i++){ my @a; $a[$i] = 99; print Dumper(\@a); }
... which results in ...
$VAR1 = [
99
];
$VAR1 = [
undef,
99
];
...actually allocated and destroyed a new array every time through the loop. Since you go around the loop twice, it seems like you don't "leave" the scope in which @a was delcared, so @a should still "be there" during the second iteration. I still don't get that.
Also, I still don't understand why the 'wrong' version creates the data structure that it does. Any thoughts on that one?In reply to Re^2: Scope and references
by {}think
in thread Scope and references
by {}think
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |