#!/usr/bin/perl -w use strict; use LWP::Simple; # file to store the update time my $speaker_prev_mod_time = '/home/qiang/bin/speaker_prev_mod'; # webpage to watch my $speaker_url = 'http://cs.senecac.on.ca/speakers/speakersFlash.html +'; # file to store the update time my $cherry_prev_mod_time = '/home/qiang/bin/cherrypick_prev_mod'; # another webpage to watch my $cherry_url = 'http://cherryavenuefarms.org/'; # update is sent to this email box. my $email = 'your@email.com'; # build the webpage hash my %checks = ( 'seneca speaker series' => { 'time_stamp' => $speaker_prev_mod_time, 'url_to_check' => $speaker_url }, 'cherry picking opening' => { 'time_stamp' => $cherry_prev_mod_time, 'url_to_check' => $cherry_url } ); foreach (my ($k,$v)=each %checks) { my $prev_mod_time = &get_prev($v->{time_stamp}); my $cur_mod_time = &get_current($v->{url_to_check}); if ($cur_mod_time ne $prev_mod_time) { &update_mod_time($cur_mod_time, $v->{time_stamp}); my $t = `/bin/echo "$v->{url_to_check} modified on $cur_mod_time\n" | /bin/mail -s "$k page just updated" $email`; } } # get current update time for the page sub get_current { my $url = shift; my @headers = head($url); scalar localtime($headers[2]); } # get prev update time for the page sub get_prev { my $file_timestamp = shift; unless (-e $file_timestamp) { open F,">$file_timestamp" or die $!; close F; return "bla bla"; } open F,$file_timestamp or die $!; my $mod_time = <F>; close F; return $mod_time; } # record the update time for the page sub update_mod_time { my ($mod_time,$file_timestamp) = @_; open F,">$file_timestamp" or die $!; print F $mod_time; close F; }

In reply to webpage update watch - used to watch event update by Qiang

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.