On Thu, 2002-01-17 at 00:55, Michael Fowler wrote: > 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.
as an idea would using reverse on the string before split be an idea, then reversing the spit strinngs + a join on $array[1],array[2] etc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]