Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: need help in creating multi dimensional array

by davorg (Chancellor)
on Feb 10, 2006 at 11:44 UTC ( #529327=note: print w/replies, xml ) Need Help??

in reply to need help in creating multi dimensional array

Perl doesn't really go in for all that restrictive nonsense. It will happily auto-vivify array elements at whatever index you give it.

You might want to look at Tie::Array::Bounded, but note that Perl doesn't actually have multi-dimensional arrays so that you'll need to restrict each array individually.


"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re: need help in creating multi dimensional array

Replies are listed 'Best First'.
Re^2: need help in creating multi dimensional array
by misterb101 (Sexton) on Feb 10, 2006 at 14:51 UTC
    yep, so if the indices in your arrays are arbitrary or if your multidimensional array is sparse (like a sparse matrix) you'd better use hashes of hashes.
    for instance if you declare $a->[10000] = 1 it also autovivivies elements 0 until 9999 setting the value to undef. This takes up unnessessary (? difficult word;) space, and makes loops much more cumputation intensive.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2023-06-01 12:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found