Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: Help update the Phalanx 100 by stvn
in thread Help update the Phalanx 100 by petdance

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found