>>>>> "AB" == Andy Bach <[EMAIL PROTECTED]> writes:

  AB> and came up w/:
  AB> sub clean_html
  AB> {
  AB>   my $string = shift;
  AB>   my @ents = split(/&/, $string);
  AB>   my $ent;
  AB>   my $new_str = shift(@ents);  # for strings starting w/ an amp
  AB>   foreach $ent ( @ents ) {

IMO this is a simpler and cleaner loop: <untested>

        s/&(#?\w{2,7});/fix_ent( $1 )/ge ;

sub fix_ent {

        my $ent = shift ;

        return "&$ent;" if $ent =~ /^#\d{3}/ ||
                           $html_entities{ lc $ent } ;
        return "&amp;$ent;" ;
}

fix up to suit your taste.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to