Re: perl code to remove newlines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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

On Thu, Dec 30, 2010 at 5:19 AM, ken <gebser@xxxxxxxxxxxx> 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.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux