Rev 45 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 45 | Rev 48 | ||
|---|---|---|---|
| Line 88... | Line 88... | ||
| 88 | 88 | ||
| 89 | ## FIXME: Why don't the defaults work already?
|
89 | ## FIXME: Why don't the defaults work already?
|
| 90 | my $formatter = new Number::Format( |
90 | my $formatter = new Number::Format( |
| 91 | -decimal_point => $decimal_point, |
91 | -decimal_point => $decimal_point, |
| 92 | -thousands_sep => $thousands_sep, |
92 | -thousands_sep => $thousands_sep, |
| 93 | - | ||
| 94 | # -grouping => $grouping[0]
|
93 | # -grouping => $grouping[0]
|
| 95 | ); |
94 | ); |
| 96 | 95 | ||
| 97 | ###################### USER CONFIGURATIONS ############################
|
96 | ###################### USER CONFIGURATIONS ############################
|
| 98 | 97 | ||
| Line 313... | Line 312... | ||
| 313 | 312 | ||
| 314 | ## DEBUG
|
313 | ## DEBUG
|
| 315 | dmsg($ua) if DEBUG; |
314 | dmsg($ua) if DEBUG; |
| 316 | }
|
315 | }
|
| 317 | 316 | ||
| 318 | ## The User Agent for User-Agent by number of posts
|
317 | ## The User Agent for User-Agent by number of articles
|
| 319 | get_agent($msg); |
318 | get_agent($msg); |
| 320 | 319 | ||
| 321 | ## Get all cross-posted newsgroups
|
320 | ## Get all cross-posted newsgroups
|
| 322 | for ( split( /,/, $msg->study('Newsgroups') ) ) |
321 | for ( split( /,/, $msg->study('Newsgroups') ) ) |
| 323 | {
|
322 | {
|
| 324 | $crossposts{$_}++; # bump count for each |
323 | $crossposts{$_}++; # bump count for each |
| 325 | }
|
324 | }
|
| 326 | 325 | ||
| 327 | ## Get threads
|
326 | ## Get threads
|
| 328 | my $thread = $msg->study('Subject'); |
327 | my $thread = $msg->study('Subject'); |
| 329 | $thread =~ s/^\s*re:\s*//i; # Remove Re: or re: at the start |
328 | $thread =~ s/^\s*re:\s*//i; # Remove Re: or re: at the start |
| 330 | $thread =~ s/\s*\(was:\s*.*\)\s*$//i; # Remove (was: ...) at the end |
329 | $thread =~ s/\s*\(was:\s*.*\)\s*$//i; # Remove (was: ...) at the end |
| 331 | $thread =~ s/\s+/ /g; # collapse whitespace |
330 | $thread =~ s/\s+/ /g; # collapse whitespace |
| 332 | $threads{$thread}{'count'}++; # bump count of this subject |
331 | $threads{$thread}{'count'}++; # bump count of this subject |
| 333 | $threads{$thread}{'size'} += $filesize; # bump bytes for this thread |
332 | $threads{$thread}{'size'} += $filesize; # bump bytes for this thread |
| 334 | 333 | ||
| 335 | ## Is this an original post or a reply?
|
334 | ## Is this an original post or a reply?
|
| 336 | if ( defined $msg->study('References') ) |
335 | if ( defined $msg->study('References') ) |
| 337 | {
|
336 | {
|
| 338 | $replies++; |
337 | $replies++; |
| Line 604... | Line 603... | ||
| 604 | {
|
603 | {
|
| 605 | #################### DISPLAY RESULTS #####################
|
604 | #################### DISPLAY RESULTS #####################
|
| 606 | print "=" x 76, "\n"; |
605 | print "=" x 76, "\n"; |
| 607 | printf "%s\n", |
606 | printf "%s\n", |
| 608 | centred(
|
607 | centred(
|
| 609 | __x( "Analysis of posts to {newsgroup}", newsgroup => $newsgroup_name ), |
608 | __x( "Analysis of articles to {newsgroup}", newsgroup => $newsgroup_name ), |
| - | 609 | 76
|
|
| 610 | 76 ); |
610 | ); |
| 611 | print "=" x 76, "\n"; |
611 | print "=" x 76, "\n"; |
| 612 | printf "%s\n", |
612 | printf "%s\n", |
| 613 | centred(
|
613 | centred(
|
| 614 | __(
|
614 | __(
|
| 615 | "(compiled with a script by Thomas 'PointedEars' Lahn, based on work by\nGarry Knight et al.)"
|
615 | "(compiled with a script by Thomas 'PointedEars' Lahn, based on work by\nGarry Knight et al.)"
|
| 616 | ), |
616 | ), |
| 617 | 76
|
617 | 76
|
| 618 | ); |
618 | ); |
| 619 | print "\n\n"; |
619 | print "\n\n"; |
| 620 | printf __"Total posts considered: %s over %d days\n", |
620 | printf __"Total articles considered: %s over %d days\n", |
| 621 | $formatter->format_number($totalposts), |
621 | $formatter->format_number($totalposts), |
| 622 | $formatter->format_number($numdays); |
622 | $formatter->format_number($numdays); |
| 623 | my $time_locale = setlocale(LC_TIME); |
623 | my $time_locale = setlocale(LC_TIME); |
| 624 | my $earliest_datetime = DateTime->from_epoch( |
624 | my $earliest_datetime = DateTime->from_epoch( |
| 625 | epoch => $earliest, |
625 | epoch => $earliest, |
| Line 637... | Line 637... | ||
| 637 | printf __"Latest article: %s\n", |
637 | printf __"Latest article: %s\n", |
| 638 | $latest_datetime->strftime($datetime_format); |
638 | $latest_datetime->strftime($datetime_format); |
| 639 | printf __"Original articles: %s; replies: %s\n", |
639 | printf __"Original articles: %s; replies: %s\n", |
| 640 | $formatter->format_number($origposts), |
640 | $formatter->format_number($origposts), |
| 641 | $formatter->format_number($replies); |
641 | $formatter->format_number($replies); |
| 642 | printf __"Total size of posts: %s bytes (%s)" . "\n", |
642 | printf __"Total size of articles: %s bytes (%s)" . "\n", |
| 643 | $formatter->format_number($totsize), |
643 | $formatter->format_number($totsize), |
| 644 | $formatter->format_bytes( $totsize, ( 'precision' => 1, 'mode' => 'iec' ) ); |
644 | $formatter->format_bytes( $totsize, ( 'precision' => 1, 'mode' => 'iec' ) ); |
| 645 | printf __"Average %s articles per day, %s per day, %s bytes per article\n", |
645 | printf __"Average %s articles per day, %s per day, %s bytes per article\n", |
| 646 | $formatter->format_number( int( $totalposts / $numdays ) ), |
646 | $formatter->format_number( int( $totalposts / $numdays ) ), |
| 647 | $formatter->format_bytes( $totsize / $numdays, ( 'mode' => 'iec' ) ), |
647 | $formatter->format_bytes( $totsize / $numdays, ( 'mode' => 'iec' ) ), |
| Line 752... | Line 752... | ||
| 752 | }
|
752 | }
|
| 753 | 753 | ||
| 754 | printf "%s\n", |
754 | printf "%s\n", |
| 755 | centred(
|
755 | centred(
|
| 756 | __x(
|
756 | __x(
|
| 757 | "Top {count} responders by original text (> 5 posts)", |
757 | "Top {count} responders by original text (> 5 articles)", |
| 758 | count => $topposters |
758 | count => $topposters |
| 759 | ), |
759 | ), |
| 760 | 76
|
760 | 76
|
| 761 | ); |
761 | ); |
| 762 | print "=" x 76, "\n"; |
762 | print "=" x 76, "\n"; |
| Line 794... | Line 794... | ||
| 794 | }
|
794 | }
|
| 795 | 795 | ||
| 796 | printf "%s\n", |
796 | printf "%s\n", |
| 797 | centred(
|
797 | centred(
|
| 798 | __x(
|
798 | __x(
|
| 799 | "Bottom {count} responders by original text (> 5 posts)", |
799 | "Bottom {count} responders by original text (> 5 articles)", |
| 800 | count => $topposters |
800 | count => $topposters |
| 801 | ), |
801 | ), |
| 802 | 76
|
802 | 76
|
| 803 | ); |
803 | ); |
| 804 | print "=" x 76, "\n"; |
804 | print "=" x 76, "\n"; |
| Line 950... | Line 950... | ||
| 950 | {
|
950 | {
|
| 951 | $count = $topagents; |
951 | $count = $topagents; |
| 952 | }
|
952 | }
|
| 953 | printf "%s\n", |
953 | printf "%s\n", |
| 954 | centred(
|
954 | centred(
|
| - | 955 | __x(
|
|
| 955 | __x( "Top {count} user agents by number of posts", count => $topagents ), |
956 | "Top {count} user agents by number of articles", |
| - | 957 | count => $topagents |
|
| - | 958 | ), |
|
| 956 | 76
|
959 | 76
|
| 957 | ); |
960 | ); |
| 958 | print "=" x 76, "\n"; |
961 | print "=" x 76, "\n"; |
| 959 | my $i = 0; |
962 | my $i = 0; |
| 960 | foreach my $agent ( |
963 | foreach my $agent ( |
| Line 982... | Line 985... | ||
| 982 | else
|
985 | else
|
| 983 | {
|
986 | {
|
| 984 | $count = $toptz; |
987 | $count = $toptz; |
| 985 | }
|
988 | }
|
| 986 | printf "%s\n", |
989 | printf "%s\n", |
| - | 990 | centred(
|
|
| 987 | centred( __x( "Top {count} time zones", count => $toptz ), 76 ); |
991 | __x( "Top {count} time zones by number of articles", count => $toptz ), |
| - | 992 | 76 ); |
|
| 988 | print "=" x 76, "\n"; |
993 | print "=" x 76, "\n"; |
| 989 | my $i = 0; |
994 | my $i = 0; |
| 990 | foreach my $zone ( sort { $tz{$b} <=> $tz{$a} } keys %tz ) |
995 | foreach my $zone ( sort { $tz{$b} <=> $tz{$a} } keys %tz ) |
| 991 | {
|
996 | {
|
| 992 | printf "%2d. %-63s : %6d\n", $i + 1, rpad( $zone, 63, "." ), $tz{$zone}; |
997 | printf "%2d. %-63s : %6d\n", $i + 1, rpad( $zone, 63, "." ), $tz{$zone}; |
| Line 1072... | Line 1077... | ||
| 1072 | 1077 | ||
| 1073 | sub dmsg2
|
1078 | sub dmsg2
|
| 1074 | {
|
1079 | {
|
| 1075 | my ( $level, @msg ) = @_; |
1080 | my ( $level, @msg ) = @_; |
| 1076 | print STDERR @msg, "\n" if $level >= DEBUG; |
1081 | print STDERR @msg, "\n" if $level >= DEBUG; |
| 1077 | }
|
- | |
| 1078 | 1082 | }
|
|
| - | 1083 | ||