my $row_html = '

test https://www.google.com

'; my $parser = MyParser->new(); $parser->parse($row_html); $parser->eof; print $parser->out; package MyParser; use parent qw(HTML::Parser); sub declaration { my ($self, $decl) = @_; $self->{'out'} .= ""; } sub start { my ($self, $tag, $attr, $attrseq, $text) = @_; if ($tag eq 'p') { $self->{'in_para'} = 1; } $self->{'out'} .= $text; } sub text { my ($self, $text) = @_; if ($self->{'in_para'}) { $text =~ s/google/duckduckgo/; } $self->{'out'} .= $text; } sub end { my ($self, $tag, $text) = @_; if ($tag eq 'p') { $self->{'in_para'} = 0; } $self->{'out'} .= $text; } sub out { my ($self) = @_; return $self->{'out'}; } 1; ####

test https://www.duckduckgo.com