"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I am starting to learn Perl by reading "Learning Perl" and testing on a Centos box. I typed in a piece of code from the book and it did exactly what the book said it should do... But I don't know why! This is the code I typed in (modded to my coding requirements):
The output of the third print is "Array: 1 2 3 4 5", exactly as the book showed. My question is why is it that way? After thinking about it my expectation was that it would be "Array: 3 2 1 4 5". I expected "unshift @lArray, @lNums" to expand to "unshift @lArray, 1 2 3" and then be processed as though:
However, it doesn't. It looks like the unshift operation is processing the values given in reverse order (3 2 1). Is this true? If not, how is it putting them in in the given order rather than reversed? Anyway, that's my problem; totally confused by Chapter 3.
|
|