I get this output now, which is just what I want. It has the number of times someone has looked at the entry, its rank in the O'Reilly system, and the title. I could also add the date of entry and other things, but I do not care about that so much.
O'Reilly Net report for 12/4/2003
Views Rank Title
------ ------ --------------------
29196 783 Controlling iTunes with Perl
23211 1131 Cleaning iTunes
400 3067 The ability to innovate
I ended up with a subclass-able package, and although I could turn this into a full distribution, I need to pack to go back to the sandbox.
I really just wanted to add a bit to the program, and it was easy enough to create the package since I had moved everything into subroutines, I just did it.
I then added a just_do_it method, which might look like a run() function from some computer sccience student's C program. I want to run the little program once the class is defined, but I want to put all the class stuff at the end because it is the less interesting stuff. For instance, the username and password is more important than the class particulars.
Now, if someone wants to turn this into a full module and release it to CPAN (please do), other people can use it while overriding some of the methods, like print_results, which is the only thing that I wanted to change in Andy's version.
my $user = "bar";
my $password = "foo";
my $verbose = 0;
my $stats = MyStats->just_do_it( $user, $password, $verbose );
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# LOTS OF STUFFED SNIPPED
my $class = shift;
my $self = $class->new( @_ );
my $self = shift;
my @times = localtime();
print "O'Reilly Net report for ",
join( "/", $times+1, $times, $times+1900 ), "\n";
The SourceForge CVS browser still seems slow to update, but you can use anonymous CVS to checkout the sources if you cannot look at them in the browser. The password is "anonymous". Enter that after using cvs login.
cvs -d:pserver:email@example.com:/cvsroot/brian-d-foy login
cvs -z3 -d:pserver:firstname.lastname@example.org:/cvsroot/brian-d-foy co ora-weblog-stats