in reply to Re: Substitution inside tags, as 1 line
in thread Substitution inside tags, as 1 line

That's a nice looking alternative, NetWallah. Not what I had in mind, but it has a certain elegence & simplicity.

Would you then suggest I put the output of that through a subsitution that removes the two "</?pre>\n</p>" matches, to finish off my requirements? How would you do it?

Thanks.

Replies are listed 'Best First'.
Re^3: Substitution inside tags, as 1 line
by NetWallah (Canon) on Oct 14, 2008 at 21:48 UTC
    Slightly uglier, getting rid of the extra </p> around the <PRE>, but still readable:
    perl -pe 'm|<pre>|..m|</pre>| and {m|</?pre>| or $_=qq|<p>$_</p>|} ' < + Your-file
    Also removed the unnecessary empty para (per mortiz, and kept it XHTML-compatible !

         Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

      Thanks again NetWallah.

      Here are some more alternatives, based on yours, which generate the output I was after, including removal of the <pre> tags. I guess your code is more correct via web standards, though.

      perl -ne 'm|<pre>|..m|</pre>| and s/\n/<p>\n/;m|</?pre>| or print' htm +lfile perl -ne 'chomp;m|<pre>|..m|</pre>| and $_.="<p>";s|</?pre><p>|| or pr +int "$_\n"' htmlfile

      Thanks for your ideas.