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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting measurements
by AnomalousMonk (Archbishop) on Aug 19, 2015 at 18:57 UTC | |
|
Re^2: Sorting measurements
by BillKSmith (Monsignor) on Aug 19, 2015 at 20:57 UTC |