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"'
In reply to Re: Re: Re: Getting IP from URL
by rob_au
in thread Getting IP from URL
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |