#! /usr/bin/perl

$field=shift;
$field="docbase" unless (defined($field ));
print $field,"\n";

@hints=();
while(<>)
{
  /^Section: ([^ \n\t]*)/ and push @hints,$1;
}
for (@hints)
{
  $hint{$_}++;
}
open ALPHA, "> ${field}_alpha";
@hints=sort keys %hint;
for (@hints)
{
  printf ALPHA "\"$_\"\t$hint{$_}\n";
}
close ALPHA;

open FREQ, "> ${field}_freq";
@hints=sort {$hint{$b} <=> $hint{$a}} keys %hint;
for (@hints)
{
  printf FREQ "$hint{$_}\t\"$_\"\n";
}
close FREQ;

