Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Re: Dereferencing hashrefsby Sweeper (Pilgrim) |
on Feb 11, 2002 at 22:28 UTC ( [id://144725]=note: print w/replies, xml ) | Need Help?? |
The {}s work like
parenthesies. I've often wondered why {}s are used
in this context, not ()s. Anybody?)
Perl was initially based on C, sh and awk. The syntax $foo is inherited from sh, and like in sh, there were some problems if the variable was followed by a string. So, like in sh, there is the alternate syntax ${foo}. And then, there is the backward compatibility Perl 1 -> Perl 2 -> Perl 3 etc. This is why curlies have remained, and are still there. There might be another reason. There is a special variable $( ($GID), so with $(foo), there would be some ambiguous parsing. There is no special variable consisting of a dollar and a single open curly, so parsing ${foo} not ambiguous.
In Section
Seekers of Perl Wisdom
|
|