Leser: 1
|< 1 2 3 4 ... 6 >| | 52 Einträge, 6 Seiten |
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
sub search {
@terms = split(/\s+/, $FORM{'terms'});
foreach $FILE (@FILES) {
open(FILE,"$FILE");
@LINES = <FILE>;
close(FILE);
$string = join(' ',@LINES);
$string =~ s/\n//g;
foreach $term (@terms) {
&Umlaute;
if ($string =~ /$term/) {
$include{$FILE} = 'yes';
last;
}
else {
$include{$FILE} = 'no';
}
}
}
}
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
43
44
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Parser;
my $html_file = './test.html';
my @search = qw(Hallo Welt test);
my $string = "";
my $parser = HTML::Parser->new(
api_version => 3,
start_h => [\&start,"self,tagname,attr"],
text_h => [\&text,"self,dtext"],
end_h => [\&end,"self,tagname"]);
print "parse...";
$parser->parse_file($html_file);
print "done\n";
for my $word(@search){
if($string =~ /$word/){
print $word," gefunden\n";
}
}
sub start{
my ($self,$tag,$attr) = @_;
if($tag eq 'div' && $attr->{class} eq 'scroll'){
$self->{search} = 1;
}
}
sub text{
my ($self,$dtext) = @_;
$string .= $dtext if($self->{search});
}
sub end{
my ($self,$tag) = @_;
if($tag eq 'div'){
$self->{search} = 0;
}
}
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
sub search {
@terms = split(/\s+/, $FORM{'terms'});
foreach $FILE (@FILES) {
open(FILE,"$FILE");
@LINES = <FILE>;
close(FILE);
$string = join(' ',@LINES);
$string =~ s/\n//g;
//////// PSEUDOCODE
foreach(@LINES != <div class="scroll">)
{
gehe zu nächster zeile in @LINES
}
wenn der string gefunden wurde lauf weiter in der funktion,
an der position wo wir in @LINES gerade sind
///////// PSEUDOCODE ENDE
foreach $term (@terms) {
&Umlaute;
if ($string =~ /$term/) {
$include{$FILE} = 'yes';
last;
}
else {
$include{$FILE} = 'no';
}
}
}
}
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
43
44
45
46
47
use HTML::Parser;
my $string = "";
sub search {
my @terms = split(/\s+/, $FORM{'terms'});
my $parser = HTML::Parser->new(
api_version => 3,
start_h => [\&start,"self,tagname,attr"],
text_h => [\&text,"self,dtext"],
end_h => [\&end,"self,tagname"]);
for my $html_file(@FILES){
$string = '';
$parser->parse_file($html_file);
foreach $term (@terms) {
&Umlaute;
if ($string =~ /$term/) {
$include{$FILE} = 'yes';
last;
}
else {
$include{$FILE} = 'no';
}
}
}
}
sub start{
my ($self,$tag,$attr) = @_;
if($tag eq 'div' && $attr->{class} eq 'scroll'){
$self->{search} = 1;
}
}
sub text{
my ($self,$dtext) = @_;
$string .= $dtext if($self->{search});
}
sub end{
my ($self,$tag) = @_;
if($tag eq 'div'){
$self->{search} = 0;
}
}
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
sub search {
@terms = split(/\s+/, $FORM{'terms'});
foreach $FILE (@FILES) {
local $/;
open(FILE,"<",$FILE) or die $!;
my $string = <FILE>;
close(FILE);
($string) = $string =~ m~<div class="scroll">(.*?)</div>~;
$string =~ s/\n//g;
foreach $term (@terms) {
&Umlaute;
if ($string =~ /$term/) {
$include{$FILE} = 'yes';
last;
}
else {
$include{$FILE} = 'no';
}
}
}
}
$string =~ s~.*<div class="scroll".*?>~~i; # loesche alles vor dem div
1
2
3
4
5
6
7
8
9
foreach $FILE (@FILES) {
local $/;
open(FILE,"<",$FILE) or die $!;
my $string = <FILE>;
close(FILE);
$string =~ s~.*<div class="scroll".*?>~~i; # loesche alles vor dem div
$string =~ s/\n//g;
$string =~ s~.*<div class="scroll".*?>~~i; # loesche alles vor dem div
|< 1 2 3 4 ... 6 >| | 52 Einträge, 6 Seiten |