?1 #!/usr/bin/perl
?2 use Inline CPP;
?3 package?MyParser;
?4 use base?"HTML::Parser";
?5
?6 my?$src='src.htm';
?7 my?$allow=0;
?8 my?%hashwords;
?9 my?@arraywords;
10
11 sub?trim
12 {
13 ????????my?$str?= $_[0];
14 ????????$str?=~ s/^/s+//o;
15 ????????$str?=~ s//s+$//o;
16 ????????return?$str;
17 }
18
19 sub?start
20 {
21 ????????my?($self,$tagname,$attr,$attrseq,$text) = @_;
22 ????????if($tagname?eq?'script'?or?$tagname?eq?'a')
23 ????????{
24 ????????????????$allow=0;
25 ????????}
26 ????????else
27 ????????{
28 ????????????????$allow=1;
29 ????????}
30 }
31
32 sub?text
33 {
34 ????????my?($self,$text) =@_;
35 ????????$text=trim($text);
36 ????????if($allow?and?$text)
37 ????????{
38 ????????????????my?@words=split(/[/s,/./)/(/':;/"]+/o,$text);
39 ????????????????foreach?my?$word(@words)
40 ????????????????{
41 ????????????????????????$word=lc($word);
42 ????????????????????????if($word=~m/^[a-z]+$/o)
43 ????????????????????????{
44 ????????????????????????????????if(not?exists?%hashwords->{$word})
45 ????????????????????????????????{
46 ????????????????????????????????????????%hashwords->{$word}=0;
47 ????????????????????????????????????????push(@arraywords,$word);
48 ????????????????????????????????}
49 ????????????????????????}
50 ????????????????}
51 ????????}
52 }
53
54 %hashwords=();
55 my?$p?= MyParser->new;
56 $p->parse_file($src);
57 @arraywords=sort(@arraywords);
58 foreach?my?$word(@arraywords)
59 {
60 ????????print?"$word/n";
61 }
62