in reply to Re: Change elements order in an array
in thread Change elements order in an array

This is what I am trying to get it:
I asked to wrong way.
$VAR1 = [ [ 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff' ], [ '111', '222', '333', '444', '555', '666' ], [ 'ppp', 'eee', 'rrr', 'lll', 'ooo', 'kkk' ], ];

Replies are listed 'Best First'.
Re^3: Change elements order in an array
by stevieb (Canon) on Oct 16, 2015 at 15:24 UTC

    Please see Re: Change elements order in an array. This node has been merged with it, and this one will be reaped.

    Per part of my post in Re: Change elements order in an array, you're wanting to modify the inner arrays. This will work. Just put your original data back in. It iterates over @AoA, and for each array reference within it, slices it to the specified order, then pushes those results within a new array reference onto the @new_aoa structure.
    my @new_order = (0, 1, 2, 3, 5, 4); my @AoA = ( [ qw(1 2 3 4 5 6), ], [ qw(a b c d e f), ], ); my @new_aoa; for (@AoA){ push @new_aoa, [@$_[@new_order]]; } print Dumper \@new_aoa;