#!/usr/local/bin/perl -w

open(IN, "global.lst");
open(OUT, ">editglob.m");
open(C_OUT, ">globcount.tmp");

while (<IN>)
{
   @fields = split(' ');
   $first = shift(@fields);
   if ($first =~ /(\w+.*):global/)
   {
      foreach $g (@fields)
      {
         if (! defined($glist{$g}))
         {  
            $glist{$g} = "";
            $count{$g} = 0;
         }
         $glist{$g} = "$glist{$g} $1";
         $count{$g}++;
      }
   }
}
   @globals = sort(keys(%glist));
   foreach $key (@globals)
   {
      print( OUT   "global $key\n");
      print( C_OUT "$key $count{$key} $glist{$key}\n");
   }

      
