http://www.perlmonks.org?node_id=33782

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (data structures)

How do I reverse an array of arrays?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I reverse an array of arrays?
by merlyn (Sage) on Sep 23, 2000 at 21:54 UTC
    First, there's no array of arrays. The closest Perl has is an array of arrayrefs.

    Second, "reverse" along what axis? The top level is simple:

    @reversed = reverse @array;

    The second level is also pretty easy:

    @second_level_reversed = map [reverse @$_], @array;
    And you can add a reverse ahead of map to do them both.