in reply to Re: Max dimensions of multi-dimensional array
in thread Max dimensions of multi-dimensional array

Can you Please explain the print statement line a little.

  • Comment on Re^2: Max dimensions of multi-dimensional array

Replies are listed 'Best First'.
Re^3: Max dimensions of multi-dimensional array
by BrowserUk (Patriarch) on Jul 13, 2016 at 09:52 UTC
    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.