in reply to Scalar value @scores_sorted[$i] better written as $scores_sorted[$i]
Let diagnostics explain:
$ echo 'Scalar value @scores[$i] better written as $scores[$i]' | spla +in Scalar value @scores[$i] better written as $scores[$i] (#1) (W syntax) You've used an array slice (indicated by @) to select a single element of an array. Generally it's better to ask for a sc +alar value (indicated by $). The difference is that $foo[&bar] always behaves like a scalar, both when assigning to it and when evaluati +ng its argument, while @foo[&bar] behaves like a list when you assign to +it, and provides a list context to its subscript, which can do weird t +hings if you're expecting only one subscript. On the other hand, if you were actually hoping to treat the array element as a list, you need to look into how references work, beca +use Perl will not magically convert between scalars and lists for you. + See perlref.
|
|---|