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.
Thank you for your help.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";
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |