Re: confusion with splitting columns using [-n, -n] (e.g; my ( $country, $bytes ) = ( split )[ -2, -1 ])



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
===== Jenda@xxxxxxxxxxx === 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

.



Relevant Pages

  • Re: OT: Censorship American style
    ... NEW YORK -- Green Day has the most popular CD in the country, ... but you won't be able to find it at your local Wal-Mart. ... they should probably have an obligation to sell people the correct ... stores. ...
    (alt.sports.baseball.bos-redsox)
  • Re: If he was a real president
    ... people who steal from stores that are abandoned? ... America has a long history of marginalizing non-whites. ... it's strange that looting is a problem in a civilised western country. ... Many Americans are descendants of slave traders and ...
    (alt.guitar.amps)
  • Re: HOW?
    ... with especially the bigger stores like in ... And it's funny how from country to country there are other albums ... And all stores had decent or better score sections. ... They used to have a magnificent soundtrack section. ...
    (rec.music.movies)
  • Re: Skyscout and Blessed Silence
    ... content are very carefully chosen by marketing psychologist-type folks. ... True of the types of stores that have marketing psychologist-type ... fans have fled to country (lesser of two evils: ... Dire Straits cut an album with Emmylou Harris. ...
    (rec.outdoors.rv-travel)
  • Re: GC Surprise...
    ... suburbias around the country. ... No stores or conveniences for folks that live ... They'll be opening a new grocery store in my town next year. ... bring up my general disdain for the suburbs and sprawl.... ...
    (rec.music.makers.guitar.acoustic)