3.2.91 mapmap
This function evaluates the @words = map { split ' ' } @lines; splits a list of lines into a list of words. Often, though, there is a one-to-one mapping between input values and output values: @chars = map chr, @nums; translates a list of numbers to the corresponding characters. And here's an example of a one-to-two mapping: %hash = map { genkey($_), $_ } @array; which is just a funny functional way to write this: %hash = (); foreach $_ (@array) { $hash{genkey($_)} = $_; }
See also
grep
.
map
differs from
grep
in that
map
returns a list consisting of the
results of each successive evaluation of |
|