> I'm particularly confused with the line: 
> "my ($country, $bytes) = (split) [-2, -1];
> 
> What does this tells? What does -2 and -1 tells? All I know is that
> split will output a list containing two values that will be assigned
> to $country and $bytes for every line of that whois.bytes file. But
> I'm not sure what those -2,-1 means and how it was able to extract
> column 5 and 6. I tried looking at perldoc -f split but cannot seem to
> find the explanation. Are those the LIMIT thing?

No these are not the LIMIT. These are array indices. You could write 
the code like this:

my @items = split;
my ($country, $bytes) = @items[-2,-1];

The 

        my @items = split;

line splits the contents of $_ on whitespace and stores the results 
in the @items array, the

        my ($country, $bytes) = @items[-2,-1];

copies the last-but-one element of @items to $country and the last 
one to $bytes.

You can use the

        (function_call( parameters))[indices]

shortcut with any function that returns several values (eg. 
localtime()), but you have to make sure you enclose the function call 
in braces.

HTH, Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to