in reply to Re: Max dimensions of multi-dimensional array -- oneliner
in thread Max dimensions of multi-dimensional array
Because you use the first element from your sorted list instead of the last.
scalar isn't needed in the sort comparison because <=> puts the two array references into scalar context any way. For your code to be strictly correct (run without error under strictures) you need to deal with undefined array elements too. The cleaned up and strictly correct code looks like:
use warnings; use strict; my @array; $array[345][10] = 1; $array[2][65535] = 1; print qq($#array x ), map {scalar @$_ - 1} (sort {@$a <=> @$b} map {$_ // []} @array)[-1 +];
Prints:
345 x 65535
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Max dimensions of multi-dimensional array -- oneliner
by Discipulus (Canon) on Jul 14, 2016 at 06:58 UTC |