#!/usr/bin/perl use strict; use warnings; use HTML::Parser; # specify events here rather than in a subclass my $p = HTML::Parser->new( api_version => 3, text_h => [\&text,"text"], default_h => [sub { print shift }, "text"], ); sub text{ my ($text) = @_; $text =~ s~(\d+)~$1~g; print $text; } while (<>) { $p->parse($_); } $p->eof;