On Wed, Jan 16, 2002 at 03:57:44PM -0800, Scott Lutz wrote:
> 
> $DOM_NAME, my $TLD) = split(/\./, $domain);
> creates two variable out of an inputted domain name, 
> 
> until this comes along:
>       domainname.org.uk
> 
> which it interprets as : 
>       $DOM_NAME = domainname
>       $TLD = org
> 
> so is it possible to do a 'greedy split' ??

Specifying a third argument to split would solve this problem how you want. 
E.g.

    my $domain = "domainname.org.uk";
    my($DOM_NAME, $TLD) = split(/\./, $domain, 2);

    $DOM_NAME eq 'domainname'
    $TLD      eq 'org.uk'

However, unless you're guaranteed that the first portion of the name will be
the domain, and the last portion will be the toplevel, this won't work in
all situations.  Given the above, www.foo.org.uk would parse as 'www' and
'foo.org.uk'.  The only solution to this problem would be to know what
toplevels you can have and parse it based on that.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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

Reply via email to