home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume3
/
newspaths
/
twoway
< prev
Wrap
Text File
|
1989-02-03
|
520b
|
19 lines
#! /usr/bin/perl
#
# twoway -- convert unidirectional counts from "newspaths" into two-way counts
# Usage: twoway file
# where file is an output from "newspaths".
$_ = <>; # Skip the Last-ID: line
while (<>) {
($n, $pair) = split (' ');
($a, $b) = split (/!/, $pair);
if ($a gt $b) { $pair = $b . "!" . $a; } # alphabetical order
$count{$pair} += $n;
}
die "Can't exec sort!\n" unless open (sort, "|sort -nr");
while (($pair, $n) = each (count)) {
printf sort ("%5d %s\n", $n, $pair);
}
close sort;