use strict; use warnings; use HTML::TokeParser; my @tags = @ARGV; @tags || die "Give a list of tags to retain.\n"; my %keep = map { lc($_) => 1, lc("/$_") => 1 } @tags; my $p = HTML::TokeParser->new(\*DATA); while ( my $t = $p->get_token ) { if ( $t->[0] =~ /S|E/ and $keep{$t->[1]} ) { print $t->[-1]; } elsif ( $t->[0] eq 'T' ) { print $t->[1]; } } __DATA__

Bang!1

Did italic and link with bold inside it.

naked link

The content of the body element is displayed in your browser.