#! /usr/bin/perl

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

@hints=();
while(<>)
{
  /needs=([^ \n\t]*)/ and $need=$1;
  /needs=([^ \n\t]*)\\$/ and $need=$1;
  /needs="([^"\n]*)"/ and $need=$1;
  /$field=/ or next;
  /$field=([^ \n\t]*)/ and $hints=$1;
  /$field=([^ \n\t]*)\\$/ and $hints=$1;
  /$field="([^"\n]*)"/ and $hints=$1;
  #print "'$need' " unless ($need =~ /^(x11|text|vc|wm)$/i);
  #next unless ($need =~ /^(x11|text|vc|wm)$/i);
  next if ($need =~ /^dwww$/i);
  push @hints,split(",",$hints);
}
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;

