blob: 8bd02dd9c4216b6232bfb042df5852420cabfcf1 (
plain)
| 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
48
49
50
51
52
53
54
55
 | #!/usr/bin/perl
use Getopt::Long;
GetOptions( 'map=s'   => \%mapping ) || die "Wrong options\n";
for $file (@ARGV) {
        open(FILE, "$file") || die "File not found: $file\n";
        $indir = 0;
        while (<FILE>) {
                if (/\<H1\>\<A NAME=\".*\" HREF=\".*\"\>(.*)\<\/A\>\<\/H1\>/) {
                        $index = $mapping{$1};
#                        print "Index: $1 => $index\n";
                } elsif (/\<DIR\>/) {
                        $indir = 1;
                } elsif (/\<\/DIR>/) {
                        $indir = 0;
                } elsif ($indir) {
                        if (/\<LI\>\<A HREF=\"([^\"]*)\"\>([^<]*)\<\/A\>/) {
                                unless ($lastindex eq $index) {
                                        if ($lastindex) {
                                                print "</$lastindex>\n";
                                        }
                                        print "<$index>\n";
                                        $lastindex = $index;
                                }
                                $name = dehtml($2);
                                $url = $1;
                                print STDOUT "<entry name=\"$name\" url=\"$url\"/>\n";
                        }
                }
        }
        close(FILE);
}
if ($lastindex) {
        print "</$lastindex>\n";
}
sub dehtml
{
        my ( $str ) = @_;
        $str =~ s/\<CODE\>//g;
        $str =~ s/\<\/CODE\>//g;
        $str =~ s/\<TT\>//g;
        $str =~ s/\<\/TT\>//g;
        return $str;
}
 |