If you want a scalar, use the scalar sigial ($). If you want an list, use the array sigil (@). While Perl won't care in most situations, it'll signal your intent to the next person to read your code.
Does that mean you disagree with the warning? Or are you like the ancient Greek who didn't consider 1 not to be a proper number, and you don't consider one-element lists to be proper lists?
I appreciate the idea that a leading $ signals you want a single element, and a leading @ signals you want a slice. But sometimes, the slice one wants is just one element.
In reply to Re^2: What is the difference between $array[1] and @array[1]?
by JavaFan
in thread What is the difference between $array[1] and @array[1]?
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |