in reply to Splice equivalent for a two-dimensional arrays
There's no such thing as a two dimentional array in Perl per say. That means you have to remove elements from multiple row arrays. That means you need a loop. Loop over every row, and splice the offending column from the referenced row array.
# Remove the 4th column. splice(@$_, 3, 1) foreach @$rows;
Update: Two swap two columns, use splice to remove one, and use splice to reinsert it at the new location.
# Swap the 3rd and 4th columns. splice(@$_, 2, 0, splice(@$_, 3, 1)) foreach @$rows;
Alternatively, create a translation map and use an array slice:
# Swap the 3rd and 4th columns. my @map = (0, 1, 3, 2, 4, 5); @$_ = @$_[@map] foreach @$rows;
|
|---|