|
|
|
|
|
by jordandanford
5633 days ago
|
|
I tried both for a while when I was getting into programming, and one huge thing that has always bothered me about Perl is the strange behavior with changing sigils. Here's what I mean: $foo is a scalar @foo is an array $foo[0] is the first element of @foo, instead of @foo[0] As far as I know, Larry Wall's rationale as a linguist was that in English, one would say "this apple" and "these apples", but "this third apple" instead of "these third apple". The problem is that code isn't a human language, and obeying these rules doesn't make sense and puts additional cognitive strain on the programmer. Basically, having different syntax quirks for scalars, arrays, hashes, and file handles makes code unnecessarily weird, especially when combining them for things like multi-dimensional arrays. |
|
you are referencing an array and returning a scalar. the sigil represents a scalar which is what is returned. A list isn't being returned, so why should the sigil represent that?