Generate new list using map in Perl
Answer:
The Perl's map function is superb cool for generating new list based on an existing list.
1. Generate new array based on an existing array
my @new = map {$_ * 2} (1, 2, 3);
# @new contains 2, 4, 6
2. Generate new hash based on an existing array
my %new = map {$_ => 1} (1,2,3);
# %new contains a hash...
# {
# '1' => 1,
# '3' => 1,
# '2' => 1
# };