... arrays expand as needed. ... the size of your array will expand to 346 x 65536 ...
That's a bit misleading. It implies the allocation of space for a | an orthogonal multi-dimensional array of 346 * 65,536 == 22,675,456 elements. Because Perl multi-dimensional arrays are "ragged", each array "dimension" (update: maybe "vector" would be a better term here) is only allocated the space it actually needs. I count the array specified in the OPed code like this:
-
@array array of 346 elements, mostly undefined;
-
$array[0] reference to an empty array;
-
$array[1] undefined, doesn't exist as an array;
-
$array[2] reference to an array of 65536 elements, only two of which are defined;
-
array elements @array[3 .. 344] are undefined;
-
$array[345] reference to an array of 11 elements, only one of which is defined.
By my count, I get a total of 346 + 65,536 + 11 == 65,893 elements, almost all of which are undefined; the array, as it stands, is very sparse.
Update: Please see Manipulating Arrays of Arrays in Perl (perllol) and Perl Data Structures Cookbook (perldsc).
Give a man a fish: <%-{-{-{-<
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.