#!/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 () { if (/\\(.*)\<\/A\>\<\/H1\>/) { $index = $mapping{$1}; # print "Index: $1 => $index\n"; } elsif (/\/) { $indir = 1; } elsif (/\<\/DIR>/) { $indir = 0; } elsif ($indir) { if (/\\([^<]*)\<\/A\>/) { unless ($lastindex eq $index) { if ($lastindex) { print "\n"; } print "<$index>\n"; $lastindex = $index; } $name = dehtml($2); $url = $1; print STDOUT "\n"; } } } close(FILE); } if ($lastindex) { print "\n"; } sub dehtml { my ( $str ) = @_; $str =~ s/\//g; $str =~ s/\<\/CODE\>//g; $str =~ s/\//g; $str =~ s/\<\/TT\>//g; return $str; } # Local Variables: # mode: perl # fill-column: 120 # End: