home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / newspaths / twoway < prev   
Text File  |  1989-02-03  |  520b  |  19 lines

  1. #! /usr/bin/perl
  2. #
  3. # twoway -- convert unidirectional counts from "newspaths" into two-way counts
  4. # Usage: twoway file
  5. # where file is an output from "newspaths".
  6.  
  7. $_ = <>;    # Skip the Last-ID: line
  8. while (<>) {
  9.     ($n, $pair) = split (' ');
  10.     ($a, $b) = split (/!/, $pair);
  11.     if ($a gt $b) { $pair = $b . "!" . $a; }    # alphabetical order
  12.     $count{$pair} += $n;
  13. }
  14. die "Can't exec sort!\n" unless open (sort, "|sort -nr");
  15. while (($pair, $n) = each (count)) {
  16.     printf sort ("%5d %s\n", $n, $pair);
  17. }
  18. close sort;
  19.