in reply to Substitution inside tags, as 1 line

... or a naive one-liner state-machine ...

perl -pe 'chomp; $s=!$s,next if s/^\s*<\/?pre>\s*$//i; $_="<p>$_</p>" +if $s; $_.="\n";' <in >out
... makes ...
in: out: ---------------------------------- <html> <html> ...etc... ...etc... <pre> <p>Line 1</p> Line 1 <p>Line 2</p> Line 2 <p>...etc...</p> ...etc... <p>Line n</p> Line n ...etc... </pre> </html> ...etc... </html>

Replies are listed 'Best First'.
Re^2: Substitution inside tags, as 1 line
by tel2 (Pilgrim) on Nov 07, 2008 at 02:24 UTC
    Weeks later...

    I like it, Perlbotics.

    Thanks for that.