Subversion Repositories LCARS

Compare Revisions

Last modification

Regard whitespace Rev 9 → Rev 8

/trunk/tools/network/news/newsstat/newsstat.pl
2,7 → 2,6
use strict;
use warnings;
use utf8;
use encoding 'utf-8';
use Encode;
 
###########################
21,10 → 20,6
 
############################################################################
# RECENT CHANGES #
# 2011-10-03 PE - Use more compatible shebang
# - Fixed some Perl::Critic-ized code
# - Fixed wrong indent for non-ASCII names (TODO: proper dot count)
# - Formatted source code
# 2011-07-03 PE - Use Encode to decode/encode MIME encodings
# - Use warnings, utf8 (just in case)
# - Documentation update
244,8 → 239,7
printf "%s\n", &centred( "Top $count posters by number of articles", 76 );
print "=" x 76, "\n";
$i = 0;
foreach
my $poster ( sort { $data{$b}{count} <=> $data{$a}{count} } keys %data )
foreach my $poster ( sort { $data{$b}{count} <=> $data{$a}{count} } keys %data )
{
my $name = substr( $poster, 0, 65 );
printf "%2d: %-63s : %6d\n", $i + 1, rpad( $poster, 63, "." ),
298,10 → 292,8
&centred( "Top $count responders by original text (> 5 posts)", 76 );
print "=" x 76, "\n";
$i = 0;
foreach my $poster (
sort { $data{$b}{percent} <=> $data{$a}{percent} }
keys %data
)
foreach my $poster ( sort { $data{$b}{percent} <=> $data{$a}{percent} }
keys %data )
{
next if $data{$poster}{quoted} == 0;
next if $data{$poster}{count} < 5;
330,10 → 322,8
&centred( "Bottom $count responders by original text (> 5 posts)", 76 );
print "=" x 76, "\n";
$i = 0;
foreach my $poster (
sort { $data{$a}{percent} <=> $data{$b}{percent} }
keys %data
)
foreach my $poster ( sort { $data{$a}{percent} <=> $data{$b}{percent} }
keys %data )
{
next if $data{$poster}{quoted} == 0;
next if $data{$poster}{count} < 5;
361,10 → 351,8
printf "%s\n", &centred( "Top $count threads by no. of articles", 76 );
print "=" x 76, "\n";
$i = 0;
foreach my $thread (
sort { $threads{$b}{count} <=> $threads{$a}{count} }
keys %threads
)
foreach my $thread ( sort { $threads{$b}{count} <=> $threads{$a}{count} }
keys %threads )
{
my $name = substr( $thread, 0, 65 );
printf "%2d: %-63s : %6d\n", $i + 1, rpad( $name, 63, "." ),
389,10 → 377,8
printf "%s\n", &centred( "Top $count threads by size in KB", 76 );
print "=" x 76, "\n";
$i = 0;
foreach my $thread (
sort { $threads{$b}{size} <=> $threads{$a}{size} }
keys %threads
)
foreach my $thread ( sort { $threads{$b}{size} <=> $threads{$a}{size} }
keys %threads )
{
my $name = substr( $thread, 0, 65 );
printf "%2d: %-63s : %6d\n", $i + 1, rpad( $name, 63, "." ),
469,10 → 455,8
printf "%s\n", &centred( "Top $count User Agents by number of posts", 76 );
print "=" x 76, "\n";
$i = 0;
foreach my $agent (
sort { $distinct_agent{$b} <=> $distinct_agent{$a} }
keys %distinct_agent
)
foreach my $agent ( sort { $distinct_agent{$b} <=> $distinct_agent{$a} }
keys %distinct_agent )
{
printf "%2d: %-58s : %5d (%2.f%%)\n", $i + 1, rpad( $agent, 58, "." ),
$distinct_agent{$agent},
555,7 → 539,7
#### First, analyse header fields ####
 
# Set up this poster if not defined, get counts, sizes
my $poster = encode( 'UTF-8', $headers{From} ); # get the poster's name
$poster = encode( 'UTF-8', $headers{From} ); # get the poster's name
if ( !defined( $data{$poster} ) )
{ # seen this one before?
$data{$poster}{agent} = 'Unknown'; # comes after For: field
781,8 → 765,7
my $percent = 100;
if ( ( $data{$poster}{orig} != 0 ) and ( $data{$poster}{quoted} != 0 ) )
{
$percent =
$data{$poster}{orig} * 100 /
$percent = $data{$poster}{orig} * 100 /
( $data{$poster}{quoted} + $data{$poster}{orig} ); #/
}
elsif ( $data{$poster}{orig} == 0 )
871,8 → 854,7
"----------------------------------------------------------------------------\n";
foreach my $thread ( sort { "\L$a" cmp "\L$b" } keys %threads )
{
print $OUTF
"$thread : $threads{$thread}{count} : $threads{$thread}{size}\n";
print $OUTF "$thread : $threads{$thread}{count} : $threads{$thread}{size}\n";
}
print $OUTF
"============================================================================\n";