#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $url = 'http://checkip.dyndns.org'; my $browser = LWP::UserAgent->new; my $response = $browser->get($url); unless ($response->is_success) { die "GET $url failed: ", $response->status_line; } unless ($response->content_type eq 'text/html') { die "$url is of type $response->content_type, was expecting text/html"; } if ($response->content =~ /.*Current\sIP\sAddress:\s(.*)<\/body.*/i) { print "$1\n"; } else { die "Failed to parse response"; }