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

meh... I think the problem is with how we're using join(). I overlooked the fact that its second parameter should be the list. Try the following (note that you may still need to use chomp() on the array as mentioned in Re^5: Parse one fiile, send the records to two different files):

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

Replies are listed 'Best First'.
Re^6: Parse one fiile, send the records to two different files
by BigRedEO (Acolyte) on May 27, 2016 at 18:51 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.

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

      print $ERR_FH $line."\n";
      poj

        ...or just do this :)

        Thank you! That's got it!

      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"; }