Re: confusion with splitting columns using [-n, -n] (e.g; my ( $country, $bytes ) = ( split )[ -2, -1 ])
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Tue, 30 Jan 2007 15:19:41 -0800
Andy Greenwood wrote:
On 1/30/07, Michael Alipio <daem0nb0y@xxxxxxxxx> wrote:
It is working perfectly but now, I need to document this code. Can
anyone help me out on understanding this code.
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?
(split) gives you an array,
Actually, it gives you a list, which you can then store in an array.
perldoc -q "What is the difference between a list and an array"
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- References:
- Prev by Date: Re: How do I output an array twice via pipe instead of only once?
- Next by Date: Re: I don't know where to start with this one.
- Previous by thread: Re: confusion with splitting columns using [-n, -n] (e.g; my ( $country, $bytes ) = ( split )[ -2, -1 ])
- Next by thread: execution of script in one shell
- Index(es):
Relevant Pages
|