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; }

In reply to your library book is due by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.