#!/usr/local/bin/perl use DB_File; #use Getopt::Std; $PROG = substr($0, rindex($0, "/") + 1); $USAGE = "Usage: $PROG indexdb [output]\n"; @indent = (' ',' ',' ',' '); sub cmp_entry { $terms_a = lc($a); $terms_b = lc($b); $terms_a =~ s/\&[a-z#0-9]+;?//sio; $terms_b =~ s/\&[a-z#0-9]+;?//sio; $terms_a =~ s/^[^a-z0-9\@:=]+//sio; $terms_b =~ s/^[^a-z0-9\@:=]+//sio; return $terms_a cmp $terms_b; } if ($#ARGV >= 0) {$db = $ARGV[0]; shift;} else {die $USAGE;} if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';} if ($#ARGV >= 0) {die $USAGE;} dbmopen(%index, $db, 0666) || die "$PROG: cannot open database $db\n;"; open(OUTPUT, ">$output") || die "$PROG: cannot create file $output\n"; # Slurp it all into memory, and sort... @sorted = sort cmp_entry (values %index); # Write it out @prev = ('', '', '', '', '', ''); $prevletter = '`'; #print OUTPUT "
"; # Note: The magic autoincrement for letters does not # work on non-alphanumeric! foreach (ord($prevletter)+1 .. ord($letter)) { # Be careful about quotes and double quotes. # Also skip uppercase, since we have # sorted case-insensitively. unless ($_ == 34 || $_ == 38 || $_ == 39 || (ord('A') <= $_ && $_ <= ord('Z'))) { print OUTPUT " "; } } print OUTPUT "\n