Similarly, if you use @array[1] as input to a function that behaves differently in list context vs. scalar context, the use of @array[1] will result in list context behavior, whereas $array[1] will result in scalar context behavior
What kind of rubbish statement is that? The scalar vs list behaviour of a function is determined by its context, not the sigils of its arguments.
Suppose you were right, what behaviour would func have below:
func $foo[1], @bar[1]
scalar, or list?
The only difference between $arr[1] and @arr[1] lie in the cases were it can give context: lvalue context. In rvalue context, there isn't one iota of difference (which, IMO, means the warning is utterly bogus if triggered in rvalue context).
There is a difference between $arr[EXPR] and @arr[EXPR], where EXPR isn't a scalar literal; the former gives scalar context to EXPR, the latter gives list context. But just where it makes a difference, Perl remains silent (rightly so, of course).
Considering this is a warning about something that can be determined by a static inspection of the code (@{$arr}[1] doesn't trigger for instance), IMO, such a warning belongs in a linter. Perl::Critic for instance. | [reply] [d/l] [select] |
No, the first one will put the first element of @another_array into @array.
> perl -e '@a=(5,6,7); @array[1] = @a; print @array;'
5
| [reply] [d/l] |