#!/usr/bin/perl use strict; use warnings; use HTML::Parser; my @found = (); my $p = HTML::Parser->new( start_h => [\&start, 'self,tagname,attr'], end_h => [\&end, 'self,tagname'], text_h => [\&text, 'self,dtext'] ); chdir("c:/users/frosch/documents/schulen/"); $p->parse_file("bw.html"); sub start { my ($self, $tagname, $attr) = @_; $self->{'div'} = 1 if $tagname eq 'div'; $self->{parse_div} = 1 if $tagname eq 'div' and $attr->{class} eq 'p'; } sub end { my ($self, $tagname) = @_; $self->{parse_div} = 0 if $tagname eq 'div'; } sub text { my ($self, $dtext) = @_; $dtext =~ s/\n\r//; push @found, $dtext if $self->{parse_div}; } for (@found) { print $_,"\n"; } print $#found," Ergebnisse.\n";