From:                   Scott Lutz <[EMAIL PROTECTED]>

> Here is the story:
> "@array" with unknown number of elements, that I want to cycle through
> while assigning variables to each value in the loop like this:
> 
> __snip__
> 
> foreach my $domain ( @DOMAINS_ORDERED ){
>         (my $DOM_NAME, my $TLD) = split(/\./, $domain, 2); #split the
>         domain
> into 2, so we can extract the "TLD"

Looks like you want the Top Level Domain, the "com", "org", "cz", 
.... right?

What if the @DOMAINS_ORDERED contain something like     
"ms.mff.cuni.cz" ?
(I even used to have an email address like 
[EMAIL PROTECTED])

You'll get the "ms" in $DOM_NAME and 'mff.cuni.cz' in $TLD.

If you really want to have the TLD in $TLD try this instead:

my ($DOM_NAME, $TLD) = ($domain =~ /^(.*)\.([^.]+)$/);

If you are sure @DOMAIN_ORDERED elements contain only one 
dot or if I understang $TLD wrong, please ignore this pestering.



Also if you want to get all the parts separated use an array:

        my @domain_parts = split /\./, $domain;

And the last part (the TLD) is in $domain_parts[-1].

Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

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

Reply via email to