> Hello, 
>  
> Does anyone know of a quick/easy/fast way to to get the 
> domain out of a url?
>  
> For instance if I do : $url = $cgi->url();
>  
> I'll get, say http://joe.mama.com/so/isyour.cgi?mother
>  
Here's a partial answer to my own question ::

$uri = URI->new($cgi->url());
$domain = $uri->host();
Will set $domain to 
sub.domain.domain.com
me.domain.com
Etc...

I tried

$domain =~ m/((\w+)\.(\w+)$)/;
print "-$domain-\n";
print "-$1-\n";

And $1 did indeed only have 'domain.com'
Then I realized, what about tld's like com.uk like yahoo.com.ru google.com.uk

IF this was used at one of those you'd only get 'com.uk' or 'com.ru'
Back to the drawing board!!


Thanks


> I know I can use URI module to get the  scheme (http, https, 
> ftp, etc) from that What I need to grab out of that example 
> is the domain only, ( mama.com ) just the part that one would 
> register with a registrar, not any subdomains or any of that 
> just whatever.com.
>  
> Any ideas?
> Can it be done with cgi or uri or some other module instead 
> of doing some regex on it that will probably let stuff get through?
>  
> Thanks
>  
> Dan
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to