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

Thank you very much Kenneth. I was looking for that word in perl language (cash) too. I read that "undef" tells perl to remove all formatting (like \n) indicators from the text. So, what does this line do?

my($u_value, $p_value, $mc_value) = (undef) x 3

thanks again for your time and great great help
  • Comment on Re^4: tab delimited extraction, formatting the output

Replies are listed 'Best First'.
Re^5: tab delimited extraction, formatting the output
by kennethk (Abbot) on Feb 09, 2009 at 23:28 UTC
    (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.
      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.