in reply to How can I make it to a one liner

Try this one:

perl -ne 'chomp;for(split /,/){print ++$i%3 ? "$_," : "$_\n" }'

Replies are listed 'Best First'.
Re^2: How can I make it to a one liner
by moritz (Cardinal) on Oct 08, 2007 at 07:50 UTC
    There are some corner cases where the different solutions disagree.

    The test file:

    a,b,c,d,e f,g,e,h i,j, l,m n ,

    greatshots' output:

    a,b,c d,e,f,g,e h,i,j,l,m,n,
    (no newline at the end)

    My output:

    a,b,c d,e,f g,e,h i,j,l m,n,
    (no trailing newline)

    ikegami's output:

    a,b,c d,e f,g e,h i,j l,m n ,

    It would be interesting to know what the desired output is (and if it matters at all)