in reply to Re: Arrays: Last-index special variable vs. scalar values
in thread Arrays: Last-index special variable vs. scalar values
(I realize this question has been settled... just thought I'd clarify the above answer so there was no need to go to the docs)
From the Camel Book 2d ed. p47
In a list context, the value of the list literal is all the
values of the list in order. In a scalar context, the value
of a list literal is the value of the final element, as with
the C comma operator, which always throws away the value
on the left and returns the value on the right. For Example:
@stuff = ("one","two","three");
assigns the entire list value to array @stuff, but:
$stuff = ("one","two","three");
assigns only the value three to variable $stuff.
----
Lists are different animals than arrays. Lists are not simply collections of literals.
You can have a list of arrays. It seems like if you evaluate a
hash in scalar context, i.e $x = (%hash); you get some funky
fraction that doesn't mean much. If you did $x = (@ary1,@ary2); you'd get
the last value of @ary2. I'm sure that's useful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Arrays: Last-index special variable vs. scalar values
by Dominus (Parson) on Nov 16, 2000 at 22:07 UTC | |
|
Re: Re: Arrays: Last-index special variable vs. scalar values
by Dominus (Parson) on Nov 16, 2000 at 22:17 UTC |