in reply to Re: Merge pairs of lines
in thread Merge pairs of lines

Now that I've actually tested the code, I have a bugfix for it:

You should test before submitting a snippet.

Even this version has a quirk you should be aware of. It will substitute a comma for a newline on the last line of the file if the input has an odd number of non-blank lines.

You can use $a ^= 1 as a sufficiently clear alternative to $a = 1 - $a.

Golfed: perl -pe 'goto LINE if!/\S/;--$|&&s/\n/,/'

Update: Another several strokes shaved:

perl -pe '/\S/?--$|&&s/\n/,/:($_="")'

-sauoq
"My two cents aren't worth a dime.";