in reply to how to convert new line to ","

#!/usr/bin/perl use warnings; use strict; my $x = do {local $/; <DATA>}; $x =~ s/\n/,/g; $x =~ s/,,+/\n/g; print $x; __DATA__ 1111 2222 3333 4444 5555 6666

Replies are listed 'Best First'.
Re^2: how to convert new line to ","
by moritz (Cardinal) on Jul 24, 2008 at 09:56 UTC
    That won't work if the data is allowed to contain commas natively.

    That's a general problem if you change data in a non-reversible way: you have to do it right in the first pass.

      Well, yes, should the original data contain commas, it's gonna be a mess anyway