"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
A very handy skill in learning Perl is gaining familiarity with documentation. I personally use the Perl documentation hosted on http://perl.org with associated hook-up to my browser search box to keep it immediately on hand. There's also the perldoc command-line utility, ActiveState bundles html-ified docs with its version, and I'm sure a plethora of other options.
For operators, there's perlop. Within that document, the => operator is documented under Comma Operator. It is identical to a comma, except to transforms a bareword left-hand argument to a string. Specifically, The => operator is a synonym for the comma except that it causes its left operand to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores.Thus it allows:
to be written as
which I find to be more intuitive. The each function has a bit of magic in it. When called with a hash, it will set an iterator in the hash and returns a key, value pair. Each subsequent call (assuming you don't use another function that sets an iterator) returns another key/value pair until they are exhausted, at which time it will return and empty list or undef depending on context. Thus, a while(each) will systematically traverse a hash. On each iteration, I use list assignment to store the key/value pair and then output them in an interpolated string. The examples in each are likely more clear than any explanation I can give. In reply to Re^3: hash problems
by kennethk
|
|