diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-02-20 09:31:59 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-02-20 09:31:59 +0000 |
commit | d8216f1923053431fae392f86b84b8e441b735f6 (patch) | |
tree | c92a0ab09b3574630584bd1a427c6f5e153398f3 /pod/perlfunc.pod | |
parent | e6aad7ab3b3b577c4589672c8421d266feb7ef77 (diff) | |
download | perl-d8216f1923053431fae392f86b84b8e441b735f6.tar.gz |
A few nits to perlfunc/map.
p4raw-id: //depot/perl@30368
Diffstat (limited to 'pod/perlfunc.pod')
-rw-r--r-- | pod/perlfunc.pod | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 6c38ab46e5..b9e17b9c49 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2827,13 +2827,13 @@ more elements in the returned value. translates a list of numbers to the corresponding characters. And - %hash = map { getkey($_) => $_ } @array; + %hash = map { get_a_key_for($_) => $_ } @array; is just a funny way to write %hash = (); - foreach $_ (@array) { - $hash{getkey($_)} = $_; + foreach (@array) { + $hash{get_a_key_for($_)} = $_; } Note that C<$_> is an alias to the list value, so it can be used to @@ -2844,8 +2844,8 @@ most cases. See also L</grep> for an array composed of those items of the original list for which the BLOCK or EXPR evaluates to true. If C<$_> is lexical in the scope where the C<map> appears (because it has -been declared with C<my $_>) then, in addition to being locally aliased to -the list elements, C<$_> keeps being lexical inside the block; i.e. it +been declared with C<my $_>), then, in addition to being locally aliased to +the list elements, C<$_> keeps being lexical inside the block; that is, it can't be seen from the outside, avoiding any potential side-effects. C<{> starts both hash references and blocks, so C<map { ...> could be either @@ -2865,7 +2865,7 @@ such as using a unary C<+> to give perl some help: %hash = map ( lc($_), 1 ), @array # evaluates to (1, @array) -or to force an anon hash constructor use C<+{> +or to force an anon hash constructor use C<+{>: @hashes = map +{ lc($_), 1 }, @array # EXPR, so needs , at end |