4 ms·
> The $ and @ that folks complain about are pretty handy tools to convey what the variable holds. It doesn't convey much. $scalar or @array, that's all. An arr
by wott 6y ago
> The $ and @ that folks complain about are pretty handy tools to convey what the variable holds.
It doesn't convey much. $scalar or @array, that's all. An array is always an array of scalars. Scalar can be almost anything: any kind of number, a string, a reference (often a reference to... an array or a hash, since you can't have arrays of arrays or array of hashes, only arrays of scalars).
- bachmeier 6y ago> It doesn't convey much. $scalar or @array, that's all. It's useful when you have a healthy mix of arrays and scalars scattered throughout your code. Static typing would be better, but $ and @ are better than tracking the information manually.
- bmn__ 6y ago> It doesn't convey much. $scalar or @array, that's all. You're vastly underinformed. It conveys the mode of access. It shows at one glance if the expression is singular or list or pairs. … of an array … of a hash the whole @a %h one particular $a[0] $h{foo} values slice @a[5,3,7] @h{qw(bar foo quux)} key/value pairs %a[5,3,7] %h{qw(bar foo quux)}