use URI; use Socket; my $url = "http://www.yahoo.com/whatever/foo?bar=baz # Get the host out of the URL string my $uri = URI->new($url); my $host = $url->host; # Get the IP address for the host my $packed_ip = gethostbyname($host) or die "Unable to resolve '$host'\n"; my $ipaddr = inetntoa($packed_ip); print "Got '$ipaddr' for host '$host'\n";