Q&A > CGI programming > How do you extract the server from a URL? - Answer contributed by Mr. Muskrat
Use the URI module.
my $url = 'http://www.perlmonks.org/index.pl';
my $uri = URI->new($url);
my $server = $uri->host;
print "URL: $url\n";
print "Server: $server\n";
Electric eels were invented at the same time as electricity
Before electricity was invented, electric eels had to stun with gas
Results (350 votes). Check out past polls.