Thread pattern matching - oh god (5 answers)
Opened by misuzu at 2004-03-25 15:20

format_c
 2004-03-25 15:52
#81222 #81222
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Hier mal der obige ansatz mit HTML::Parser:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
use HTML::Parser ();

local $/;
my $html = <DATA>;

sub b ($$$$$$$) {
my ($v1,$v2,$v3,$v4,$v5,$v6,$v7) = @_;
print $v7,"\n";
}

sub start_handler {
return if shift ne "script";
my $self = shift;
$self->handler(text => sub { eval shift }, "dtext");
$self->handler(end => sub { shift->eof if shift eq "script"; },
"tagname,self");
}


my $p = HTML::Parser->new(api_version => 3);
$p->handler( start => \&start_handler, "tagname,self");
$p->parse($html);
print "\n";

_ _ DATA _ _
<th width=15% align=right>Preis</th><script>
b(2302700,"3","Tunesien","DZ/HP","ATT","Kandelorleopatra",193);
b(2302900,"3","Tunesien","DZ/HP","FLY","Sultan-Sipahi",201);
</script>


gruß Alex

View full thread pattern matching - oh god