http://www.perlmonks.org?node_id=67825


in reply to statswhore.pl

The following simplistic patch adds reports that differentiate between Re: nodes reputation and top-level articles reputation, based on the idea that those two categories are often voted on differently.

--- statswhore_old.pl Wed Mar 28 15:27:03 2001 +++ statswhore.pl Wed Mar 28 15:24:24 2001 @@ -59,13 +59,44 @@ $total += @$_[1] for (@$rarticles); @$rarticles = sort {@$a[1] <=> @$b[1]} @$rarticles; + # added by darobin + my (@top_articles,@re_articles); + my $top_total = 0; + my $re_total = 0; + for my $art (@$rarticles) { + $art->[0] =~ s/^node_id=\d+://i; + if ($art->[0] =~ /^\s*Re:/i) { + push @re_articles, $art; + $re_total += $art->[1]; + } + else { + push @top_articles, $art; + $top_total += $art->[1]; + } + } + @top_articles = sort { $a->[1] <=> $b->[1] } @top_articles; + @re_articles = sort { $a->[1] <=> $b->[1] } @re_articles; + print "\n"; - print sprintf (" User: %s\n", $username); - print sprintf (" Total articles: %d\n", $#$rarticles + 1); - print sprintf (" Total reputation: %d\n", $total); - print sprintf (" Min reputation: %d\n", @$rarticles [0]->[1] +); - print sprintf (" Max reputation: %d\n", @$rarticles [-1]->[1 +]); - print sprintf ("Average reputation: %3.2f\n", $total / ($#$rarticl +es + 1)); + print sprintf (" User: %s\n", $userna +me); + print sprintf (" Total articles: %d\n", $#$rart +icles + 1); + print sprintf (" Total reputation: %d\n", $total) +; + print sprintf (" Min reputation: %d\n", @$rarti +cles [0]->[1]); + print sprintf (" Max reputation: %d\n", @$rarti +cles [-1]->[1]); + print sprintf (" Avg reputation: %3.2f\n\n", $tota +l / ($#$rarticles + 1)); + + print sprintf (" Total top-level posts: %d\n", scalar @to +p_articles); + print sprintf ("Total top-level post reputation: %d\n", $top_total +); + print sprintf (" Max top-level post reputation: %d\n", $top_artic +les[-1]->[1]); + print sprintf (" Min top-level post reputation: %d\n", $top_artic +les[0]->[1]); + print sprintf (" Avg top-level post reputation: %3.2f\n\n", (@top +_articles)?($top_total / scalar @top_articles):0); + + print sprintf (" Total reply posts: %d\n", scalar @re +_articles); + print sprintf (" Total reply post reputation: %d\n", $re_total) +; + print sprintf (" Max reply post reputation: %d\n", $re_articl +es[-1]->[1]); + print sprintf (" Min reply post reputation: %d\n", $re_articl +es[0]->[1]); + print sprintf (" Avg reply post reputation: %3.2f\n", (@re_ar +ticles)?($re_total / scalar @re_articles):0); + print "\n"; }

-- darobin