in reply to adding an index column to a multi-array derived from a csv data file
It works for me.
my @arr = ([1,1], [2,2], [3,3]); # [[1, 1], [2, 2], [3, 3]] $_->[2] = $i++ for @arr; # [[1, 1, 0], [2, 2, 1], [3, 3, 2]]
Are you sure your @multi_array contains array refs? If so, is the last index 1, such that assigning to index 2 will add a new element? The data in your previous post has a length of 3 elements, so index 2 is already populated.
You could generalise to:
$_->[$#{$_}+1] = $i++ for @arr; # or push @{$_}, $i++ for @arr;
|
|---|