http://www.perlmonks.org?node_id=991123


in reply to Parsing CSV only returns the second line of the file

Anyone knows where I'm doing something wrong?

One loop inside another, without adequate understanding of files and modulus operator

$ perl -le " for(1..20){printf qq{%s %s\n}, $_, int($_ % 1 ); } " 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0

Replies are listed 'Best First'.
Re^2: Parsing CSV only returns the second line of the file
by saint_geser (Initiate) on Sep 01, 2012 at 07:00 UTC

    Could you please elaborate on that. I don't know much about perl, you're right but it is really annoying to do all these files by hand.

      Could you please elaborate on that.

      Find places in your code, say, a loop inside a loop, where you use the modulus operator, say like "% 1"

      Then compare that line to my code, esp the output

      When do you think that inner loop will end?

      Here is a better one, what do you think the inner while loop does, what is its purpose?

      Here is another hint, how many times do you get this warning (after you add the code)?  if( warn "calling parse " and $csv->parse($_) ) {