I use Fraser Valley Regional Library a lot (BC Canada). The library allows me to check online whether I have any book due, but it is a pain to key in bar code, password, etc every time, and the library does not provide the service of sending me email alert whether I have any book due. So I come up with this little script to help myself.

use LWP::UserAgent; #Time::localtime is not really used use Time::localtime; use Data::Dumper; use strict; use warnings; my $data = [ ["name" => "Liz", "code" => "1234567890", "pin" => "06 +09"], ["name" => "Peter", "code" => "1234567890", "pin" => " +0609"], ["name" => "Jimmy", "code" => "1234567890", "pin" => " +0609"], ]; my @books = (); my $today = sprintf("%02d-%02d-%02d", localtime->mday(), localtime->mo +n(), localtime->year() % 100); print "Today is: " . $today . "\n"; my $ua = new LWP::UserAgent(); for my $index (0 .. $#{@$data}) { my $res = $ua->post("http://catalogue.fvrl.bc.ca/patroninfo.asp", +$data->[$index]); my $content = $res->content(); $content =~ m/\/(\d{1,})\//s; parse($ua->post("http://catalogue.fvrl.bc.ca/patroninfo/$1/patfram +eitems", $data->[$index])); } sort_book(); print Dumper(\@books); sub parse { my $response = shift; my $content = $response->content; $content =~ m/<table.*?>(.*?)<\/table>/s; $content = $1; my @items = split /checkbox/, $content; for (1 .. $#items) { my $item = $items[$_]; $item =~ m/\)">(.*?)<\/a>/s; my $description = $1; $item =~ m/DUE (.{8})/s; my $due = $1; push @books, $due. "\t" . $description; } } sub sort_book { @books = sort { $a =~ /(\d*)-(\d*)-(\d*)/; my $keya = "$3$2$1"; $b =~ /(\d*)-(\d*)-(\d*)/; my $keyb = "$3$2$1"; return $keyb cmp $keya; } @books; }