#! /usr/bin/perl use strict; use warnings; use HTML::Parser; my @texts; my $string = qq~   Land    Deutschland   ... ~; my $p = HTML::Parser->new(); $p->handler(start => \&start_handler,"tagname,attr,self"); $p->parse($string); print $_,"\n" for @texts; sub start_handler{ return if(shift ne 'td'); my $self = shift; my $text; $self->handler(text => sub{$text = shift;},"dtext"); $self->handler(end => sub{push @texts,$text if shift eq 'td'},"tagname"); }