Hi,
On my recent journey of learning Perl, I at times got caught up not knowing when to use a $ as against a @ or %. Beginning Perl Book stated it beautifully so I came to know that the prefix ($ @ %) represents what I want to get, not what I have. While reading up more on the context part, I came across this awesome document on Perldocs that's aught to be shared.
Consider the first paragraph for example in the link below where it states -
Perl has three built-in data types: scalars, arrays of scalars, and associative arrays of scalars, known as "hashes". A scalar is a single string (of any size, limited only by the available memory), number, or a reference to something (which will be discussed in perlref). Normal arrays are ordered lists of scalars indexed by number, starting with 0. Hashes are unordered collections of scalar values indexed by their associated string key.
And consider this statement - "Scalar values are always named with '$', even when referring to a scalar that is part of an array or a hash. The '$' symbol works semantically like the English word "the" in that it indicates a single value is expected."
I love PerlDocs. :)
On my recent journey of learning Perl, I at times got caught up not knowing when to use a $ as against a @ or %. Beginning Perl Book stated it beautifully so I came to know that the prefix ($ @ %) represents what I want to get, not what I have. While reading up more on the context part, I came across this awesome document on Perldocs that's aught to be shared.
Consider the first paragraph for example in the link below where it states -
Perl has three built-in data types: scalars, arrays of scalars, and associative arrays of scalars, known as "hashes". A scalar is a single string (of any size, limited only by the available memory), number, or a reference to something (which will be discussed in perlref). Normal arrays are ordered lists of scalars indexed by number, starting with 0. Hashes are unordered collections of scalar values indexed by their associated string key.
And consider this statement - "Scalar values are always named with '$', even when referring to a scalar that is part of an array or a hash. The '$' symbol works semantically like the English word "the" in that it indicates a single value is expected."
I love PerlDocs. :)
No comments:
Post a Comment