The stupid question is the question not asked | |
PerlMonks |
Re: if array contain push another arrayby Athanasius (Archbishop) |
on Nov 22, 2017 at 03:36 UTC ( [id://1203987]=note: print w/replies, xml ) | Need Help?? |
Hello zw, and welcome to the Monastery! First, there is a right brace (curly bracket) missing, but that’s hard to see because of the way the code is formatted. A little reformatting —
— and the missing brace is easily seen. Second, you have use strict (good!), so $element needs to be declared with my:
Third, $element is a scalar variable, which on each iteration of the loop holds a single element of the @column array. But the expressions $element[16] and $element[10] reference an entirely different variable, an array named @element which you haven’t declared. In the case of $element[16], you probably just want to use $element. In the case of $element[10], I’m not sure what you want to do; maybe you meant $column[10]? Fourth, Perl syntax requires that you make each comparison separately:
Fifth, note that in the above snippet I have removed the extra quotation marks. Your problem description implies that you want to test for equality with the character u, not with the 3-character string "u" as you have in your code. Sixth (and finally!), I think the logic of your inner foreach loop is questionable. Do you want to push to @transcript_id on each match in the line, or only once per line if a match is found? If the latter, you need to break out of the loop after the first match:
Hope that helps,
In Section
Seekers of Perl Wisdom
|
|