Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Help update the Phalanx 100

by stvn (Monsignor)
on Dec 21, 2004 at 04:47 UTC ( [id://416384]=note: print w/replies, xml ) Need Help??


in reply to Help update the Phalanx 100

So, I am giving some thought to this,... but in the meantime I thought it would be interesting to see just some very basic raw download counts. In particular to see raw download counts on my own modules. (After all, CPAN doesn't automatically give this type of info and its not everyday you get access to nicely cleaned up logs like this) So I whipped this up, just grep the raw log for a PAUSE id and pipe the output into this script (passing in 'module' or 'distro' or nothing for both).

#!/usr/bin/perl use strict; use warnings; my ($by_module, $by_distro); ($by_module, $by_distro) = (1, 1) unless @ARGV; while (my $arg = shift(@ARGV)) { $by_module = 1 if lc($arg) =~ 'module'; $by_distro = 1 if lc($arg) =~ 'distro'; } my %total_downloads_by_module; my %total_downloads_by_distro; while (<>) { my ($url) = /\d{5}\s(.*)/; my @path = split /\// => $url; my $module_distro = pop @path; $total_downloads_by_distro{$module_distro}++ if $by_distro; if ($by_module) { my ($module) = ($module_distro =~ /(.*?)\-\d\..*?.tar\.gz/); $total_downloads_by_module{$module}++; } } format_report("Total Downloads by Module", %total_downloads_by_module) + if $by_module; format_report("Total Downloads by Distro", %total_downloads_by_distro) + if $by_distro; sub format_report { my ($header, %hash) = @_; print "+---------------------------------------\n"; print "| $header\n"; print "+------+--------------------------------\n"; print join "\n" => map { "| " . sprintf("%4d", $hash{$_}) . " | " . $_ } sort { $hash{$a} <=> $hash{$b} } keys %hash; print "\n+------+--------------------------------\n"; }

BTW - The reg-exp for extracting the module name is horrible and could use a lot of help (*hint* *hint*).

-stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://416384]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found