in reply to Re^4: tab delimited extraction, formatting the output
in thread tab delimited extraction, formatting the output

(undef) x 3 creates a three element array consisting of three null values. Those three values are then mapped to the variables on the left hand side. Strictly speaking, the code my($u_value, $p_value, $mc_value); will have the same effect, but I like to explicitly initialize variables, coming from my programming background.

Replies are listed 'Best First'.
Re^6: tab delimited extraction, formatting the output
by zzgulu (Novice) on Feb 12, 2009 at 15:47 UTC
    quick question: why script goes out of the loop and exit if it finds a null value for $p_value? How can I fix it?
      I'm a little surprised that the loop exits on null values, but the fix is easy. When used in a logical context, null values and zeros evaluate to false. The easy solution is to test values with the defined function in place of just testing the value ( i.e. replace while (my $data_ref = $csv->getline($fh)) with while (defined(my $data_ref = $csv->getline($fh))) ). This will only return false if the value in the tested variable is undef.
        mmm, I guess that was not the problem. The text file that I am prcessing is very larg, it has over 8 million lines and the utterance that scripts aborts at(without any error message)is at line 43,100. The only unusual thing that I noticed first near the last utterance processed was that the column in front of p ($p_value) was empty. The last utterance was "History of present illness:" my nlp software (MMTX) prases it into three phrases : "History","of present illness" and "" which is actaully the punctuation":" First I thought ":" is the problem but apparently it is not since there are multiple instances before this one from the very first lines. Do you think this is a size/buffer issue?