in reply to Re: Re: Getting IP from URL
in thread Getting IP from URL
use Socket; use URI; my $url = 'http://www.mydomain.com'; my $uri = URI->new( $url ); my $ip_addr = gethostbyname( $uri->host ); $ip_addr = inet_ntoa( $ip_addr ); if ( $uri->host eq $ip_addr ) { #... Creatures evolve, code does stuff }
The advantage that this method of employing the URI module over a simple regular expression is the correct handling of more complex URLs (which may incorporate username and password authentication details in the form of scheme://username:password@host:port/) and validation of IP addresses.
perl -e 'print+unpack("N",pack("B32","00000000000000000000000111001001")),"\n"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Getting IP from URL
by PodMaster (Abbot) on Oct 05, 2002 at 10:49 UTC | |
by rob_au (Abbot) on Oct 06, 2002 at 10:51 UTC |