Extract domain name

D

David Kroeber

* Shabam:
How do you fetch just the domain name part of a variable in a script? The
variable can be "http://www.domain.com/blahblah/whatever/page.htm" or
"http://sub.domain.com/blahblah/whatever/page.htm".

What I need is to extract just the "domain.com".

try something like:

my(undef, undef, $domain) = $s =~
/^(http|ftp|whatever):\/\/(www|ftp|whatever)\.(.+?)\//;

There might be some module that does what you're looking for (check
CPAN), I didn't look for it, actually...

bye
//Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top