in reply to Max dimensions of multi-dimensional array

use List::Util qw[ max ]; my @array = []; $array[2][3] = 1; $array[345][10] = 2; $array[2][65535] = 10; ;; print $#array, 'x', max( map $#{ $_ // [] }, @array );; 345 x 65535

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Max dimensions of multi-dimensional array
by ravi45722 (Pilgrim) on Jul 13, 2016 at 09:22 UTC

    Can you Please explain the print statement line a little.

      print $#array, 'x', max( map $#{ $_ // [] }, @array );;
      1. $#array is the largest index of @array;
      2. $#{ $_ } is the largest index of the array referenced by $_
      3. map assigns each of the values in @array to $_ in turn.
      4. Many of them will be undefined, if so, // [] substitutes an empty array for that value.
      5. Thus, the map extracts the highest indexes of all the subarrays in @array and substitutes 0 for those that are empty or don't exist.
      6. max() finds and returns the largest of those.

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.