Elegant is in the eye of the beholder.

I'd tend to use a pipeline

        perl -lpe 's/\s+$//'|uniq

but I'm sure others find other approaches more elegant. Mine is
admittedly not perl-only, but "|uniq" is probably quicker to type
than even a golf winner for eliminating extra blank lines. It does
have the weakness that it'll also eliminate duplicate non-blank
lines, that doesn't bother me, may make it a misfit for your job. I
suppose a canonical perl-only approach could start

        perl -0777 -pe 's/[ \t]+\n/\n/g;s/\n{2,}/\n/g'

or thereabouts (untested)

-Bennett

Attachment: msg02491/pgp00000.pgp
Description: PGP signature

Reply via email to