Yes it can be confusing to a novice how Perl sigils work. Hence Larry Wall conceded this as an issue and so one of the reasons he went for invariant sigils in Perl6.
However there is logic in the madness. Perhaps Larry Wall/linguistic logic but none the less it does work! The best explanation i've see is the comment by "Matt S Trout" on devolving-sigils blog post (http://blog.fogus.me/2009/02/26/devolving-sigils/).
Below is the key sentence from mst comment:
Actually, perl sigils don’t denote variable type
– they denote conjugation
– $ is ‘the’, @ is ‘these’, % is ‘map of’ or so
– variable type is denoted via [] or {}.
Comments
Yes it can be confusing to a novice how Perl sigils work. Hence Larry Wall conceded this as an issue and so one of the reasons he went for invariant sigils in Perl6.
However there is logic in the madness. Perhaps Larry Wall/linguistic logic but none the less it does work! The best explanation i've see is the comment by "Matt S Trout" on devolving-sigils blog post (http://blog.fogus.me/2009/02/26/devolving-sigils/).
Below is the key sentence from mst comment: