The part causing troubles is:Well. $id comes from @ids. Where does @ids come from?and the uninitialized value is *** $id. ***.foreach my $id (@ids) { if ($id eq $NSC) { print MY $line; } }
You declare @ids about 20 ish lines above, and then populate the array with (reformatted, for clarity)
foreach my $row (@ids_table) { my @allcolumns = split /\t/, $row; if($count==0) { $myID= trim($allcolumns[0]); } else { $ids[$count] = trim($allcolumns[0]); } $count++; }
You perform different actions on your input when $count is zero, but you're still adding it to the array with $ids[$count] = ... inside the else block. So, $ids[0] is always going to be undefined.
If you want to add something to the end of an array, use push, not subscripts.
In reply to Re: Uninitialized value in string eq error but I initialized
by FunkyMonk
in thread Uninitialized value in string eq error but I initialized
by karpatov
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |