$array is used later in code not shown as it is not relevant to the question.
How that array would be used or accessed, is obviously very relevant to how it would be built. Yes, your code seems fixable, but it's not impossible that your code had to be rewritten (so it's more elegance, or faster, or more readable, or more efficient, whatever your goal) if we knew more information about what it's prepared for.
it sounds like you don't have an alternative to hardcoding the dimensions, either!
Oh, I'm sorry to dissapoint you. Just because I don't provide it here doesn't mean I don't have one. The things is, I refused to do what you might expected me to do due the reason I gave here. I'm not as wise as many monks here, but I'm free to choose how or what I reply, and you're free to choose any reply that most suits you, as well.

And why do you think my reply was solely to solve your problem? The reason I posted here is so we (and it's not just you and me) can all learn from each other, both our mistakes and rightness. That's what, as far as I understand it, a community-based forum is for.

Immediate update: I forgot to say that.... Nevertheless, you actually present a pretty interesting situation I upvoted the node.


Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re^3: multidimensional arrays by naikonta
in thread multidimensional arrays by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.