in reply to Uninitialized value in string eq error but I initialized
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Uninitialized value in string eq error but I initialized
by Anonymous Monk on Jan 06, 2008 at 00:46 UTC | |
by chromatic (Archbishop) on Jan 06, 2008 at 03:30 UTC |