in reply to Confused as to why the "casting context" is mis-behaving
... @array[$n] is a one-element array...
No. As philipbailey has pointed out, it is a (single element) list, and a list is not an array, and an array is not a list! ikegami has many postings on the differences between the two, but I can't come up with a good one at the moment; try Super Search.
Update: For another difference between arrays and lists:
>perl -wMstrict -le "my @ra = qw(a b c d); print qq{@ra}; for my $elem (@ra) { print ++$elem; } print qq{@ra}; ;; for my $elem (qw(a b c d)) { print ++$elem; } " a b c d b c d e b c d e Modification of a read-only value attempted at -e line 1.
|
---|