#!/usr/bin/perl -w # # getr4listing: # Obtain the Radio 4 listing from the BBC. # # Copyright (c) 2002 Chris Lightfoot. All rights reserved. # Email: chris@ex-parrot.com; WWW: http://www.ex-parrot.com/~chris/ # my $rcsid = '$Id: getr4listing,v 1.1 2002/05/31 19:27:32 chris Exp $'; $email = 'foo@bar.com'; # your email address @lines = `lynx -dump -hiddenlinks=ignore -nolist 'http://www.bbc.co.uk/cgi-perl/whatson/search/daylist.cgi?service_id=49700'`; die "could not retrieve listing" unless @lines; open(SENDMAIL, "|sendmail $email"); print SENDMAIL < Subject: Radio 4 daily listing EOF $disp = 0; foreach (@lines) { if (/^\s*$/) { print SENDMAIL "\n" if $disp; $disp = 0; } if (/^\s+\d\d:\d\d/) { $disp = 1; s/^\s*//; } if (/^\s*[A-Z][a-z]+ \d{1,2} [A-Z][a-z]+\s*$/) { # Date of listing. s/^\s*//; print SENDMAIL; } print SENDMAIL if $disp; } print SENDMAIL <