Perl: the Markov chain saw | |
PerlMonks |
Re^5: Seeking Perl docs about how UTF8 flag propagates - lists and arraysby Discipulus (Canon) |
on May 19, 2023 at 10:26 UTC ( [id://11152300]=note: print w/replies, xml ) | Need Help?? |
Hello raygun, in effect the difference is subtle and can fade into equivalence, but see it from this point of view: a list is not a Perl data type. Perl has three main variable types: scalars, arrays, and hashes. (perlintro). In Learning Perl - third edition is stated this way: > A list is an ordered collection of scalars. An array is a variable that contains a list. In Perl, the two terms are often used as if they're interchangeable. But, to be accurate, the list is the data, and the array is the variable. You can have a list value that isn't in an array, but every array variable holds a list Sometimes, just to make things more foggy, you can do operations on list in the same way as you do with array: print +( qw(J A P H) )[2] prints P but you cant shift a list and the doc goes: shift ARRAY but for example print accepts a list: print LIST Another key concept is LIST in respect of context and here it overlaps with array: LIST or SCALAR context: in list context you can assign it to an array, but again, the array is the perl variable and the list is its value. See also: What is the difference between a list and an array? and Scalars, Lists, and Arrays L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|