in reply to (tye)Re2: Trying to pass a hash of hash of lists
in thread Trying to pass a hash of hash of lists
Otherwise we'd have to update a ton of documentation and do s/list/list or array/.
No, whenever a list is wanted, an array can be used because arrays evaluate to lists in list context. An array can be "downgraded" to list, but a list can never be an array without explicitly creating an array (either through the anonymous array reference constructors ([]) or an array assignment).
There are places where it is important to distinguish "arrays" from "lists" but perllol.pod is not such a place.
Of all places, perllol should know better. It's a very technical document, that serves as a tutorial for many people. It's important not to confuse beginners (and experts). String and number are converted on the fly in Perl, but saying that Foo is a number is wrong: it's a strings that evaluates to a number (0) in numeric scalar context (which can only be created by numeric operators). You can use a string as if it were a number, and you can use a number as if it were a string, but numbers and strings will never really be the same. You can use an array as if it were a list, (not the other way around, ) but arrays are not lists.
I could rant at how wrong you are for using "array" when you can't put an array in an array.
And right you would be.
| scalar (numeric -- string -- boolean) | list | |
| undef | 0 -- "" -- false | - |
| number | 123 -- "123" -- 0 ? false : true | - |
| string | 0 -- "foo" -- "" or "0" ? false : true | - |
| reference | 255 -- "TYPE(0xFF)" -- true | - |
| array | number of elements | the elements themselves |
| list | last element | the elements themselves |
| hash | number of keys | a list of keys and values (interleaved) |
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|