in reply to (tye)Re: Trying to pass a hash of hash of lists
in thread Trying to pass a hash of hash of lists
IMO, an array is a list.
An array, when used in list context, evaluates to its elements. When used in scalar context, it evaluates to its number of elements. (You'll also notice that there is no "array context", just as there is no "hash context".) Consider:
# A list (1, 2, 1, 2, 3); # An array @array; # Array assignment (ARRAY = LIST) @array = (1, 2, 1, 2, 3); # List in list context print (1, 2, 1, 2, 3); # 12123 # Array in list context print @array; # 12123 # List in scalar context print scalar (1, 2, 1, 2, 3); # 3 (not 5!!) # Array in scalar context print scalar @array; # 5 (not 3!!)
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re2: Trying to pass a hash of hash of lists
by tye (Sage) on Mar 14, 2002 at 18:13 UTC | |
by Juerd (Abbot) on Mar 14, 2002 at 18:57 UTC |