BTW, if anybody's curious what my leader board program looks like, here it is:
#!perl
use strict;
use Time::Local;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET POST);
my %months = (January => 0, February => 1, March => 2,
April => 3, May => 4, June => 5,
July => 6, August => 7, September => 8,
October => 9, November => 10, December => 11);
my $ua = LWP::UserAgent->new();
my $postNo = 0;
my $page = $ua->request(GET "http://www.jacksonheightslife.com/community/index.php?topic=648.$postNo");
my($lastPage) = $page->content =~ /Pages:.*<a.*?href=".*topic=648\.(\d+)/;
my(%lastWord, %numPosts);
my($lastFrom, $lastTime);
POSTS:
my @posts = $page->content =~ /(<tr>(?:.(?!<\/tr>))*?View the profile of.*?<\/tr>)/gs;
foreach my $post (@posts) {
my($from) = $post =~ /View the profile of ([^"]+)/;
my($datetime) = $post =~ /on:<\/b> (.*?) &/;
my($month, $day, $year, $hour, $min, $sec, $ampm);
if ($datetime =~ /<b>(Yesterday|Today)<\/b> at (\d{2}):(\d{2}):(\d{2}) (\w{2})/) {
($hour, $min, $sec, $ampm) = ($2, $3, $4, $5);
if ($1 eq 'Today') {
($day, $month, $year) = (localtime)[3, 4, 5];
} else {
($day, $month, $year) = (localtime(time - 86_400))[3, 4, 5];
}
} else {
($month, $day, $year, $hour, $min, $sec, $ampm) = $datetime =~ /(\w+) (\d{2}), (\d{4}), (\d{2}):(\d{2}):(\d{2}) (\w{2})/;
$year -= 1900;
$month = $months{$month};
}
if ($hour == 12) {
if ($ampm eq 'AM') {
$hour = 0;
}
} else {
if ($ampm eq 'PM') {
$hour += 12;
}
}
my $time = timelocal($sec, $min, $hour, $day, $month, $year);
if (not defined $lastFrom) {
$lastFrom = $from;
$lastTime = $time;
} else {
$lastWord{$lastFrom} += ($time - $lastTime);
$lastFrom = $from;
$lastTime = $time;
}
$numPosts{$from}++;
}
if ($postNo < $lastPage) {
$postNo += 15;
$page = $ua->request(GET "http://www.jacksonheightslife.com/community/index.php?topic=648.$postNo");
goto POSTS;
}
$lastWord{$lastFrom} += (time - $lastTime);
print "[u]TLW Leader Board as of " . localtime() . "[/u]\n";
foreach my $from (sort { $lastWord{$b} <=> $lastWord{$a} } keys %lastWord) {
my $time = $lastWord{$from};
my $days = sprintf "%d", $time / 86_400; $time -= $days * 86_400;
my $hours = sprintf "%d", $time / 3600; $time -= $hours * 3600;
my $minutes = sprintf "%d", $time / 60; $time -= $minutes * 60;
my $seconds = sprintf "%d", $time;
my $dayLabel = $days == 1 ? 'day' : 'days';
my $houLabel = $hours == 1 ? 'hour' : 'hours';
my $minLabel = $minutes == 1 ? 'minute' : 'minutes';
my $secLabel = $seconds == 1 ? 'second' : 'seconds';
my $posLabel = $numPosts{$from} == 1 ? 'post' : 'posts';
print "$from: $numPosts{$from} $posLabel, last word for $days $dayLabel, $hours $houLabel, $minutes $minLabel and $seconds $secLabel\n";
}