in reply to Uninitialized value in string eq error but I initialized

I would bet it's because one of your input lines doesn't have enough columns, and, in particular, doesn't have the $colN-th column.

When $columns[$colN] is undefined, then trim returns undef which makes $NSC undefined causing the Uninitialized value in string eq error message.

To check this, right after spliting the columns just put in a check like:

... while ($line = <ALL>) { my @columns = split /,/, $line; warn "column $colN not found" unless defined($columns[$colN]); ...

Replies are listed 'Best First'.
Re^2: Uninitialized value in string eq error but I initialized
by Anonymous Monk on Jan 05, 2008 at 22:54 UTC
    Thanks for the answer(s).
    definitely the colum is there. It is a middle column and I am getting the error literally thousandtimes (every line I guess).

    The part causing troubles is:

    foreach my $id (@ids) { if ($id eq $NSC) { print MY $line; } }
    and the uninitialized value is *** $id. ***. And it causes the error, I get the result but probably because thousands of error messages it takes longer time. Could the error be caused by the fact that i declared my @ids=()? I will check those libraries definitely, but it would take a begginer some time, so I am still seeking my error. Tx. to all karpatov
      Well I incorported the recommended warn code (and will use the trick latter as well), but it is not executed, and the error is really on every single line :-(.