[CentOS] perl code to remove newlines

Fri Dec 31 03:59:47 UTC 2010
Bart Schaefer <barton.schaefer at gmail.com>

(Drat, keyboard glitch caused that to be sent before I was finished.)

On Thu, Dec 30, 2010 at 5:19 AM, ken <gebser at mousecar.com> wrote:
>
>
> --------- begin snippet ---------
> while (<$in>)
> {
>    s/<(\w*\W)/<\L$1/g;         # Downcase XXX in "<XXX".
>    s/<\/(\w*\W)/<\/\L$1/g;     # Downcase XXX in "</XXX".

  chomp;  # Always remove the newline
  unless (/<html/) {
      # Not on first line, so insert a newline
      # whenever this line does not begin with >
      s/^(^[>])/\n$1/;
  }
}

That's it, except for an END block to print a final newline.  If there
are blank lines in the input that you want to retain, you'll need a
little more to avoid having them swallowed.