2 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<td class="column1">
<input type="submit" name="Button1" value="Hinzufuegen" id="Button1" class="add" />
12345
<br />
<span class="verkauf">
67890
</span>
<br />
</td>
</tr>
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
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/perl
use strict;
use warnings;
use HTML::Parser;
use Data::Dumper;
my @numbers;
my $string = qq~Dein HTML~;
my $p = HTML::Parser->new();
$p->{numbers} = [];
$p->handler(start => \&start_handler,"tagname,attr,self");
$p->handler(end => \&end_handler,"self,tagname");
$p->handler(text => \&text_handler, "self,dtext");
$p->parse($string);
print Dumper(\@numbers)
sub start_handler{
my ($tag,$attr,$self) = @_;
return if($tag ne 'input');
return unless($attr->{name} =~ /^Button\d+$/);
$self->{bool} = 1;
}
sub end_handler{
my ($self,$tag) = @_;
if($tag eq 'td'){
$self->{bool} = 0;
push @numbers,$self->{numbers} if(scalar @{$self->{numbers}} > 0);
$self->{numbers} = [];
}
}
sub text_handler{
my ($self,$text) = @_;
$text =~ s/^\s+//;
$text =~ s/\s+$//;
if($self->{bool} and $text =~ /^\d+$/){
push @{$self->{numbers}},$text;
}
}
2 Einträge, 1 Seite |