Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Multidimensional arrays

by Bod (Parson)
on Jun 06, 2023 at 15:52 UTC ( [id://11152658]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11152658]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found