There are a number of problems in the snippet of code below, and I fail to see the solution. I have read this node (duplicates in arrays) and this node (duplicates in arrays/hashes), to no avail.

First, I know the initial foreach loop does not work this way. I had solved by putting the while (<input>) on top of it and splitting the lines directly into @line. But what I want is what I try to write below (@data is an array of arrays from a tab delimited file).

Second, the loop breaks because of the if clause that is supposed to catch duplicates. But it looks o.k. to me.

Third, and most important, the three dimensional array of arrays I think I am creating does not materialize in the test. I quite sure I'm making a mistake with the references to arrays but can't come up with the solution.

foreach @line (@data) { for my $tree (0..17) { for my $stem (0..10) { for my $height (0..2) { if (@line[0]==$tree and @line[ +1]==$stem and @line[2]==$height) { if (defined $mdarray[$ +tree][$stem][$height]) { print "there's a dupli +cate stem!\n" } else { $mdarray[$tree][$stem] +[$height]=[@line]; } } } } } } print "Test: @{$mdarray[1][1][1]}\n";
Thank you for your help.

In reply to Fail to see referencing problem to arrays (in an array of arrays) by Elias

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.