#!/usr/local/bin/perl use IO::Socket::INET; use warnings; use strict; my $ip; my $sock = IO::Socket::INET->new('checkip.dyndns.org:80'); if ($sock) { print $sock 'GET / HTTP/1.0',"\n\n"; } while (<$sock>) { if ($_ =~ /body/) { /(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})/; $ip = $1; } } `echo $ip > ~/.myIP`;