#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $start=5000; my $ua = LWP::UserAgent->new(); my $out; my %monkdays; if ($ARGV[0] eq "readfile"){readfile()} open ($out,">>","monkdays.txt") or die "Can't open file because $!"; while ($start < 10000) { my $req = HTTP::Request->new(GET=>"http://tinymicros.com/pm/index.php?goto=monkstats&sortopt=7&sortlist=10%2C1%2C3&start=$start&"); my $result = $ua->request($req); my $content; if ($result->is_success){$content= $result->content} else {last} for (split/<\/TR>/,$content) { my (@fields)= $_=~ /(.*?)<\/NOBR>/g; my $nick; my $first; if ($fields[2] =~ /HREF/ && ($fields[3]=~/^[2005|2006]/)) { ($nick) = $fields[2]=~/blank">(.*?)<\/A>/; ($first) = $fields[3]=~/(\d+\-\d+\s+)/; } else { next } # push @{$monkdays{$first}},$nick; print $out "$nick - $first\n"; } print $out "$start\n"; $start +=50; sleep 15; } sub readfile { my $in; open ($in,"<","monkdays.txt") or die "Shan't! $!"; while (<$in>) { if ($_ =~/^\d+$/){next} my ($nick,$first) = split / - /,$_; push @{$monkdays{$first}},$nick; } for (sort keys %monkdays) { print $_."\n"; for (@{$monkdays{$_}}) { print $_."\n"; } print "\n"; } exit; } #### se strict; use warnings; my %months; my @m = qw (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); for (0..11) { $months{$_+1} = $m[$_]; } my $file; open ($file,"<","md.txt") or die "shan't! $!\n"; my %mdays; my ($month,$day); while (<$file>) { chomp $_; if ($_ =~ /(\d{2})-(\d{2})/) { $month = $1; $day = $2; $month +=0; $day +=0; # make sure these scalars are properly numeric } elsif ($_ eq "") { next } else { push @{$mdays{$month}->{$day}},$_; } } #use Data::Dump::Streamer; #my $dump = Data::Dump::Streamer->new(); #$dump->Dump(%mdays)->Out(); print ""; for (my $month=1;$month<=12;$month++) { print "\n"; for my $day (sort {$a<=>$b} keys %{$mdays{$month}}) { print ""; } print ""; print "\n"; }
$months{$month}
$day
"; for my $monk (@{$mdays{$month}->{$day}}) { print "$monk
"; } print "