in reply to Re: Re: Re: Getting IP from URL
in thread Getting IP from URL

There really isn't any need for that socket stuff.
use URI; my $url = 'http://foo.bar.com'; my $uri = new URI($url); if( $uri->host =~ /[a-zA-Z\-]/ ) { # or /[^\d\.]/ # it's an IP dag-nabbit }

____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Getting IP from URL
by rob_au (Abbot) on Oct 06, 2002 at 10:51 UTC
    Agreed, this approach does simplify things somewhat - The incorporation of the Socket stuff does however have the advantage of ensuring that the IP address (hostname) extracted is valid.

     

    perl -e 'print+unpack("N",pack("B32","00000000000000000000000111001010")),"\n"'