Do Perl's sigils have anything to do with memory allocation? [duplicate]
Possible Duplicate:
Why do Perl variables need to start with $, %,@?
Other scripting languages seems to get along just fine without this or something similiar.
I guess it has something to do with memory allocation and helping the interpreter in order to speed things up, but I couldn't find anything specific on it. $scalar would probably be put into stack, @array into heap and %hash? Into heap as well? And what about ?subroutine? Could someone help me figure this out or point me to some documentation? I am still trying to grasp some fundam开发者_JS百科entals and understand how everything works under the hood...Because it makes it easier to read.
You know which identifiers are nouns, and whether they're singular or plural, because of the sigaldry. It's the same reason in English we have singular and plural determiners and agreement, as in this species is vs these species are. It's nice to know which is which.
Perl stores all data associated with a name in a single symbol table entry. The structure stored there is called a typeglob. The values for $foo
, @foo
, %foo
, and &foo
(subroutine reference) are all stored in the typeglob for "foo". The entire typeglob is denoted *foo
(where *
indicates "all sigils"). All this is explained in the perldata section of the Perl documentation.
精彩评论