| ▲ | zahlman 4 hours ago | |||||||
I remember trying to use the new "reference" feature (when it was new), with "blessing" and so on and so forth, to try to create real data structures, and finding in some way or another that it was just not regular. I can't recall the details, but something along the lines of a feeling that the syntax worked differently for, say, the top level of a tree (or first index of a multidimensional array, etc.) vs the rest of the structure. | ||||||||
| ▲ | darrenf 3 hours ago | parent [-] | |||||||
In the main, the sigil refers to the type of the eventual value, regardless of what contains it. The tl;dr is that you mostly use `$` unless you're wanting more than one value, or to dereference (when you use the sigil for the type of reference). Some examples:
Where things become a bit less regular is the difference between reference and non-reference for hashes and arrays when they are top level. At the top level, you need a `->` but that becomes optional at levels below (because at levels below, they have to be references).
And then there's stuff like getting a slice out of an arrayref
So... yeah. | ||||||||
| ||||||||