#!/usr/bin/perl use HTML::PullParser; my $doc = <<'EOF'; my %options = (); abc   abc <% abc ( ' abc   abc %>', $abc ); %> EOF foreach ( qw{ start end comment declaration default process text } ) { $options{$_} = "\"$_\", text"; } my $p = HTML::PullParser->new ( doc => $doc, %options ); my $output = ""; print "DEBUG --------------------------------------------------------------\n"; while ( my $token = $p->get_token() ) { print "$token->[0]: '$token->[1]'\n"; my $text = $token->[1]; $text =~ s|abc|abc|g if $token->[0] eq 'text'; $output .= $text; } print "--------------------------------------------------------------------\n"; print $output;