in reply to Sorting measurements

Since Perl doesn't support two-dimensional arrays

Um, actually Perl does:

#!/usr/bin/perl use strict; use warnings; my @twoDArray = ( [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13] ); # Avoiding indexes for my $rows (@twoDArray) { for my $value (@$rows) { print "$value "; } print "\n"; } print "\n"; # Using indexes for my $rIdx (0 .. $#twoDArray) { for my $vIdx (0 .. $#{$twoDArray[$rIdx]}) { print "$twoDArray[$rIdx][$vIdx] "; } print "\n"; }

Prints:

1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 9 10 11 12 13

In fact Perl supports as many dimensions as you want and actually allows mixtures of arrays, hashes and various scalar types as well in arrays.

Premature optimization is the root of all job security

Replies are listed 'Best First'.
Re^2: Sorting measurements
by AnomalousMonk (Archbishop) on Aug 19, 2015 at 18:57 UTC
    ... Perl supports as many dimensions as you want and actually allows mixtures of arrays, hashes and various scalar types as well in arrays.

    Jenny1990: Please see perldsc, perllol. (Update: Oops, RichardK beat me to one of these — should have read everything before posting!)


    Give a man a fish:  <%-{-{-{-<

Re^2: Sorting measurements
by BillKSmith (Monsignor) on Aug 19, 2015 at 20:57 UTC
    When I was first learning perl, I read that "perl does not support two dimensional arrays". (Sorry I do not remember where) I was confused because I had examples of source code which clearly used them. I now consider the discrepancy to be one of viewpoint. Perl does not have a data type similar to the multidimensional array of other languages. Perl does provide an alternate indexing syntax which allows us to use an array-of-arrays exactly as if it were a two-dimensional array. I do not think it matters how the support is implemented. GrandFather has shown us that it is available and how to use it.
    Bill