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";
Throwing nuclear weapons into the sun
Making everybody on Earth disappear
A threat from an alien with a mighty robot
A new technology or communications medium
Providing a magic fish to a Miss Universe
Establishing a Group mind
Results (195 votes). Check out past polls.