in reply to Re^3: Parse one fiile, send the records to two different files
in thread Parse one file, send the records to two different files

Nope! STILL didn't work! Now it jumbled it all the fields from the "error" records together into one just line with spaces and no commas. My errorFiles.csv has just one line with every field from the error records.

if (!length $fields[28]) { print $ERR_FH join (',', $_) for @fields; } else
...is what I'm using. So what else could be missing?

Replies are listed 'Best First'.
Re^5: Parse one fiile, send the records to two different files
by BrowserUk (Patriarch) on May 27, 2016 at 18:32 UTC

    You need  print $ERR_FH join (',', @fields );


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^5: Parse one fiile, send the records to two different files
by stevieb (Canon) on May 27, 2016 at 18:33 UTC
      So close - all the commas are now back in, but it's still putting all the fields in as one big long sole record.

        If I understand you correctly, you're getting a single line now, yes? Try adding a newline to the joined string:

        if (!length $fields[28]) { chomp @fields; my $str = join ',', @fields; print $ERR_FH "$str\n"; }

        Why not just print the original line with the new line ending you chomped replaced ?

        print $ERR_FH $line."\n";
        poj
Re^5: Parse one fiile, send the records to two different files
by stevieb (Canon) on May 27, 2016 at 18:25 UTC

    Does chomp on the array reflect in any change?:

    if (!length $fields[28]) { chomp @fields; print $ERR_FH join (',', $_) for @fields; }
      No - that did not do it either. It's as if it's not joining the fields back together with the commas to print each line. It's still writing every field that is not empty into the errorFiles.csv with a space in between each field as one continuous line.