in reply to Re^2: Replace spaces with commas and write to other file
in thread Replace spaces with commas and write to other file

sufi:

You just about have it. You're replacing all whitespace with commas. The problem is that the end of line \n is a whitespace character. You're turning it into a comma. You should chop off the end of line before you do your replacement, and then you can add it back when you print the line. Then you'll have solved your problem.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: Replace spaces with commas and write to other file
by fidesachates (Monk) on Feb 14, 2011 at 18:16 UTC
    Safer to use chomp.