Code Sample |
#!/usr/bin/perl # Useage : citytime.pl somecity use strict; use warnings; my $URL = "http://www.timeanddate.com/worldclock/"; #================================ my $city = shift; my $download = "/tmp/times.html"; if (!$city) {die "No city specified"}; print "Downloading time from $URL\n"; # legal system("wget -O $download $URL &>/dev/null"); open(CONT, $download) or die("Could not open $download"); while (<CONT>){ if (/$city.+?(\d{1,2}\:\d+\d+ (AM|PM))/i) { print "$city $1\n"}; } |
Code Sample |
$ /opt/citytime.pl tokyo Downloading time from http://www.timeanddate.com/worldclock/ tokyo 12:30 AM |