Say I build the following multidimensional array:
my @array; # don't need the empty list
my @other_array = (0 ... 10);
foreach my $i ( 0 .. 10 ) {
$array[$i] = [ @other_array[1..$#other_array] ];
}
I would like to collect a “column” of this multidimensional array into a separate array,
For example, if I want to collect the items in the first column, I would like something like
my @other_array = ();
@other_array = $array[:][1]; # This does NOT work in Perl
Is there a way to do this in Perl without looping?
Eventually what I want to do is get the array of max of each column of my multidimensional array.
PS: This question is inspired by this other question: Building and printing a multidimensional list in Perl without looping.
I think you want:
Another language might have a special syntax for this operation, but it would still be performing a loop under the hood.