This code: push(@{$matchedfiles[$c]}, [ ... ]); Is incorrect. ...But I don't see a problem with auto-vivification in this case. Consider this test code:
The first push not only creates $m[3] as an array ref, but also sets $m[0], $m[1] and $m[2] to undef. The second push changes $m[2] from undef to a new array ref.use Data::Dumper; my @m; my $c; $c = 3; push(@{$m[$c]}, [ 'foo' ]); $c = 2; push(@{$m[$c]}, [ 'bar' ]); print Dumper(\@m), "\n"; for (0..3) { print "length of m[$_] = ", scalar(@{$m[$_]}), "\n"; }
The last for loop shows that undef is basically indistinguishable from [], i.e. a reference to an empty array.
In reply to Re^2: Uninitialized value in concatenation (.) or string?
by pc88mxer
in thread Uninitialized value in concatenation (.) or string?
by jbush82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |