| 1,11 → 1,11 |
| #!/usr/bin/env perl |
| #!/usr/bin/perl |
| use strict; |
| use warnings; |
| use utf8; |
| use Encode; |
| |
| ########################### |
| # newsstat.pl version 0.4.1 |
| ######################### |
| # newsstat.pl version 0.4 |
| |
| ############################################################################ |
| # Collect statistics about a newsgroup (specified by first argument) in |
| 239,7 → 239,7 |
| printf "%s\n", ¢red( "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 $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, "." ), |
| 265,7 → 265,7 |
| printf "%s\n", ¢red( "Top $count posters by article size in Kbytes", 76 ); |
| print "=" x 76, "\n"; |
| $i = 0; |
| foreach my $poster ( sort { $data{$b}{size} <=> $data{$a}{size} } keys %data ) |
| foreach $poster ( sort { $data{$b}{size} <=> $data{$a}{size} } keys %data ) |
| { |
| my $name = substr( $poster, 0, 62 ); |
| printf "%2d: %-63s : %6d\n", $i + 1, rpad( $poster, 63, "." ), |
| 292,7 → 292,7 |
| ¢red( "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} } |
| foreach $poster ( sort { $data{$b}{percent} <=> $data{$a}{percent} } |
| keys %data ) |
| { |
| next if $data{$poster}{quoted} == 0; |
| 322,7 → 322,7 |
| ¢red( "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} } |
| foreach $poster ( sort { $data{$a}{percent} <=> $data{$b}{percent} } |
| keys %data ) |
| { |
| next if $data{$poster}{quoted} == 0; |
| 515,8 → 515,8 |
| } |
| |
| # now read the file |
| open(my $FILE, $filename) or die "Can't open $filename: $!\n"; |
| while (<$FILE>) |
| open( FILE, $filename ) or die "Can't open $filename: $!\n"; |
| while (<FILE>) |
| { |
| $totheader += length($_); # bump total header size |
| last if (/^\s*$/); # end of header? |
| 527,8 → 527,8 |
| $lcheader{ clean( lc($key) ) } = clean($val); |
| } |
| } |
| @body = <$FILE>; # slurp up body |
| close($FILE); |
| @body = <FILE>; # slurp up body |
| close(FILE); |
| } # getarticle |
| |
| ################################### |
| 741,7 → 741,7 |
| sub countagents |
| { |
| POSTER: |
| foreach my $poster ( keys %data ) |
| foreach $poster ( keys %data ) |
| { |
| foreach my $agent_name ( keys %distinct_agent ) |
| { # check against known ones |
| 760,7 → 760,7 |
| ############################################ |
| sub fixpercent |
| { |
| foreach my $poster ( keys %data ) |
| foreach $poster ( keys %data ) |
| { |
| my $percent = 100; |
| if ( ( $data{$poster}{orig} != 0 ) and ( $data{$poster}{quoted} != 0 ) ) |
| 838,50 → 838,50 |
| ################################### |
| sub writedata |
| { |
| open my $OUTF, ">/tmp/XDATA" or die "Can't create XDATA: $!\n"; |
| print $OUTF "Data collected from alt.os.linux.mandrake\n\n"; |
| print $OUTF |
| open OUTF, ">/tmp/XDATA" or die "Can't create XDATA: $!\n"; |
| print OUTF "Data collected from alt.os.linux.mandrake\n\n"; |
| print OUTF |
| "Poster Data\nname : agent : count : size: orig : quoted : per cent\n"; |
| foreach my $name ( keys %data ) |
| { |
| print $OUTF |
| print OUTF |
| "$name : $data{$name}{agent} : $data{$name}{count} : $data{$name}{size} : $data{$name}{orig} : $data{$name}{quoted} : $data{$name}{percent}\n"; |
| } |
| print $OUTF |
| print OUTF |
| "============================================================================\n"; |
| print $OUTF "Thread subjects\n"; |
| print $OUTF |
| print OUTF "Thread subjects\n"; |
| print OUTF |
| "----------------------------------------------------------------------------\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 |
| print OUTF |
| "============================================================================\n"; |
| print $OUTF "Cross-posts\n"; |
| print $OUTF |
| print OUTF "Cross-posts\n"; |
| print OUTF |
| "----------------------------------------------------------------------------\n"; |
| foreach my $name ( sort keys %crossposts ) |
| { |
| print $OUTF "$name : $crossposts{$name}\n"; |
| print OUTF "$name : $crossposts{$name}\n"; |
| } |
| print $OUTF print $OUTF |
| print OUTF print OUTF |
| "============================================================================\n"; |
| print $OUTF "User agents\n"; |
| print $OUTF |
| print OUTF "User agents\n"; |
| print OUTF |
| "----------------------------------------------------------------------------\n"; |
| foreach my $name ( sort keys %agents ) |
| { |
| print $OUTF "$name : $agents{$name}\n"; |
| print OUTF "$name : $agents{$name}\n"; |
| } |
| print $OUTF |
| print OUTF |
| "============================================================================\n"; |
| print $OUTF "Time zones\n"; |
| print $OUTF |
| print OUTF "Time zones\n"; |
| print OUTF |
| "----------------------------------------------------------------------------\n"; |
| foreach my $name ( sort keys %tz ) |
| { |
| print $OUTF "$name : $tz{$name}\n"; |
| print OUTF "$name : $tz{$name}\n"; |
| } |
| close $OUTF; |
| close OUTF; |
| } # writedata |