#!/usr/bin/env perl use strict; use warnings; use LWP::Simple; use Regexp::Common qw/net/; my $ip; for ( 0 .. 9 ) { chomp( $ip = get('http://ip-addr.es/') ); last if defined $ip and $ip =~ /$RE{net}{IPv4}/; sleep 1; } ...