#!/usr/bin/perl -wT
use strict;
use LWP::Simple;
use XML::Simple;
use Time::Local;
use Text::BarGraph;
my $startid = shift || 128020;
my $endid = shift || 128303;
my $xmlurl = "http://perlmonks.org/index.pl?node_id=37150";
my $user = 'blakem';
my $pass = 'yeahright';
## Ask the perlmonks XML engine about the nodes
my $queryurl = $xmlurl . '&nodes=' . join(',',$startid .. $endid) .
"&user=$user&passwd=$pass&op=login";
my $nodeinfo = XMLin(get $queryurl);
## Tally what hour they were posted in %nodecount
my %nodecount;
for my $node (@{$nodeinfo->{NODE}}) {
my ($year,$mon,$mday,$hours,$min,$sec) =
$node->{createtime} =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
$year -= 1900;
$mon--;
my $time = timegm($sec,$min,$hours,$mday,$mon,$year);
my $hour = (localtime($time))[2];
# print $node->{node_id} .": ". localtime($time) . " => $hour\n";
$nodecount{sprintf("%02d",$hour)}++;
}
# print out a bargraph
my $g = Text::BarGraph->new();
$g->{num} = 1;
print $g->graph(\%nodecount);
=head1 OUTPUT ( New nodes per hour for 11/28 in PST )
00 ( 7) ################
01 ( 3) #######
02 ( 7) ################
03 ( 6) ##############
04 ( 3) #######
05 ( 7) ################
06 (17) ########################################
07 (29) #############################################################
+########
08 (16) ######################################
09 (28) #############################################################
+#####
10 (16) ######################################
11 (23) ######################################################
12 (19) #############################################
13 (26) #############################################################
14 (25) ###########################################################
15 (17) ########################################
16 ( 2) ####
17 ( 5) ###########
18 ( 3) #######
19 ( 4) #########
20 (10) #######################
21 ( 7) ################
22 ( 1) ##
23 ( 3) #######
=head2 Output for a one-month sampling period...
00 (122) ##################
01 (173) ##########################
02 (176) ##########################
03 (187) ############################
04 (160) ########################
05 (241) ####################################
06 (307) ###############################################
07 (440) ############################################################
+#######
08 (399) ############################################################
+#
09 (439) ############################################################
+#######
10 (408) ############################################################
+##
11 (411) ############################################################
+##
12 (444) ############################################################
+########
13 (368) ########################################################
14 (347) #####################################################
15 (281) ###########################################
16 (256) #######################################
17 (243) #####################################
18 (207) ###############################
19 (177) ###########################
20 (188) ############################
21 (149) ######################
22 (127) ###################
23 (112) #################
|