#!/usr/local/bin/perl ################################################################### # Computer Algebra System SINGULAR # # doc2idx.pl: utility to index file for singular manual # # Prints to stdout lines of the following form # # $indexentry\t$nodename\t$url\t$chksum # # where $indexentry: entries of index (all lower case) # $nodename : name of node where index entry occurred # $url : url of node # $chksum : checksum of help text, if library proc node # lines are sorted alphabetically w.r.t. $indexentry #### $Usage = <) { if (/Node: Index/) { while () { last if /\* Menu:/; } ; while () { last if /^\s*$/; if (/^\* (.*?): (.*)\.$/) { $entry = $1; $node = $2; } $entry =~ s/\s*(.*) <\d+>\s*$/$1/; $node =~ s/^\s*(.*)\s*$/$1/; $index->{$entry}->{Node} = $node unless $entry eq $prev; $prev = $entry; } last; } } close(HLP); while () { ($entry, $url) = split(/\t/); $url =~ s/^\s*(.*)\s*$/$1/; $index->{$entry}->{Url} = $url; } close(URL); for $entry (sort keys %$index) { print "$entry\t$index->{$entry}->{Node}\t$index->{$entry}->{Url}\t$CHECKSUMS{$entry}\n"; }