Created
August 14, 2012 14:31
-
-
Save davorg/3349798 to your computer and use it in GitHub Desktop.
Command line program to check recorded post via the UK Post Office
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use LWP::Simple; | |
my $url = 'http://www.postoffice.co.uk/track-trace?trackNumber=XX' . | |
'&page_type=rml-tracking-details'; | |
my $track = shift || die "Need a tracking number\n"; | |
$url =~ s/XX/$track/; | |
my $page = get $url; | |
die "No reply\n" unless $page; | |
my ($status) = $page =~ m|<h2>Results</h2><p>(.*?)</p>|; | |
$status =~ s/\s\s+/ /g; | |
say $status; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment