in reply to Re: Multidimensional arrays
in thread Multidimensional arrays

Thanks choroba

The correct syntax is $price[1][1]

Can you tell I don't use multidimensional arrays very often?

I suppose I was thinking of multidimensional hashes which I think have a different name...
$hash{'dimension', 'type'};

Replies are listed 'Best First'.
Re^3: Multidimensional arrays
by choroba (Cardinal) on Jun 06, 2023 at 16:00 UTC
    $hash{'dimension', 'type'};

    Yes, these exist and are equivalent to

    $hash{ join $;, qw( dimension type ) }
    Not something you should use normally. Probably not even worth remembering, but you already did.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Not something you should use normally. Probably not even worth remembering, but you already did

      I remembered them because I have a bit of legacy code that produces them from an HTTP file upload...

      $file{$fileid, 'filename'}; $file{$fileid, 'content'};

      I don't use it for new stuff but there is quite a bit of existing code that still uses so I have to deal with it on occasion. I am guessing that's what I read that shouldn't be used now rather than multidimensional arrays.

Re^3: Multidimensional arrays
by hv (Prior) on Jun 06, 2023 at 16:02 UTC

    The multidimensional hashes were actually used for multidimensional array (or hash) emulation, before references were added in perl5 to make those and more complex structures far easier. The old style is still supported, but modern reference-based structures are almost always preferable: see $SUBSCRIPT_SEPARATOR.

    Also, there is nothing wrong with multidimensional arrays. In fact they are so useful, they even have their own manpage: perllol.

      Also, there is nothing wrong with multidimensional arrays

      Thanks hv.
      I feel I was thinking about multidimensional hashes when I recall reading that they shouldn't be used now. See my reply to choroba Re^4: Multidimensional arrays