#!/usr/bin/perl -w use LWP::Simple; use strict; use vars qw( $url $want @html ); # URL - Change north to whatever region you require # north, greater_london, scotland, southern_england, # midlands, wales $url = 'http://www.rac.co.uk/check_traffic/north/?&nav&view=Standard'; $want = 'M62|A58|A629'; # See if we are looking for different roads $want = ($ARGV[0]) ? $ARGV[0] : $want; $want =~ s/\,/\|/g; print "Getting reports for $want\n"; # Get the information from RAC @html = split(/\n/,get("$url")); # Did it barf? if($#html == -1) { print STDERR "RAC Site unavailable\n"; exit; } # Parse foreach (@html) { next unless(/Incident ID/); next unless(/$want/); s/<[^>]*>//g; # Remove html s/(\w+)/\u\L$1/g; # Remove nasty caps ## Nice of the RAC to conveniently put pipes in :) my ($area, $time, $report) = split(/\|/); $time =~ s/ //g; # Tidy up the time print "\n$area ($time)\n"; # Spit it out print "$report\n"; } exit;