#!/usr/bin/perl # # Histogram generator # (c) 1996 Heiko W.Rupp # # # run histogram.pl < size-file # # size-file is generated with a INN feed like # # # size-all:*:Tf,WB: # while(<>) { chop; $sum=$sum+$_; $count++; $bytes=int($_); if ($bytes < 5001) { $ro=int($bytes/50)*50; $lt5++; } elsif ($bytes >5000 && $bytes < 15001) { $ro=int($bytes/500)*500; } else { $ro=int($bytes/5000)*5000; } $rou=sprintf("%6.0d",$ro); $bucks{$rou}++; $lt9++ if ($bytes < 9001 ); $lt64++ if ($bytes < 64001 ); } print "Total: ",$sum," Bytes\n"; print "Count: ",$count," Articles\n"; print $lt5," Articles with less than 5001 bytes, "; printf "%2.2f %%\n",100*($lt5/$count); print $lt9," Articles with less than 9001 bytes, "; printf "%2.2f %%\n",100*($lt9/$count); print $lt64," Articles with less than 64001 bytes, "; printf "%2.2f %%\n",100*($lt64/$count); print "Average: ",int($sum/$count)," Bytes/Article\n"; print "Histogram is:\n"; $maxi=0; foreach $b (%bucks) { $by=$bucks{$b}; $maxi=$by if $by > $maxi; } print "\n"; $maxl=$maxi/40.0; printf "(Each + represents at least %2.2f Articles)\n",$maxl; print "Actual sizes are round down \n\n"; foreach $b (sort %bucks) { next if $bucks{$b} eq ""; print "Size: ",$b," Articles: "; printf "%7.0d ",$bucks{$b}; print "+" x int($bucks{$b}/$maxl); print "\n"; }