Bah, that won't handle nested font tags properly, this is better
#!/usr/bin/perl -- use warnings; use strict; use HTML::TreeBuilder; my $html = <<'__HTML__'; <p>and a <font face="Verdana">one <a href="link.html">two</a> three</f +ont> four</p> <p>another |<font name="one">one</font>| and another |<font name="two" +> one </font>|</p> <p>6 nested font tags <font>1<font>2<font>3<font>4<font>5<font>6</font>5</font>4</font>3</fo +nt>2</font>1</font> </p> __HTML__ { my $h = HTML::TreeBuilder->new_from_content($html); print $h->as_HTML('<>&',' ',{}), "\n"; for my $font( $h->look_down(_tag => q{font}) ){ $font->replace_with_content( $font->content_refs_list ); } print $h->as_HTML('<>&',' ',{}), "\n"; } __END__ <html> <head> </head> <body> <p>and a <font face="Verdana">one <a href="link.html">two</a> three< +/font> four</p> <p>another |<font name="one">one</font>| and another |<font name="tw +o"> one </font>|</p> <p>6 nested font tags <font>1<font>2<font>3<font>4<font>5<font>6</fo +nt>5</font>4</font>3</font>2</font>1</font></p> </body> </html> <html> <head> </head> <body> <p>and a one <a href="link.html">two</a> three four</p> <p>another |one| and another | one |</p> <p>6 nested font tags 12345654321</p> </body> </html>

In reply to Re^2: Removing font tags using HTML::TreeBuilder by Anonymous Monk
in thread Removing font tags using HTML::TreeBuilder by wfsp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.