map

for,foreachとほぼ同じだが変換を明示的にできる

#!/usr/bin/perl

my %testmap={ 'hoge' => 'A' , 'foo' => 'B' , 'bar' => 'C' };
my @keys=('hoge','foo','bar');

my @result = map {
        $testmap{$_};
}@keys;

print join(',',@result) . '\n';

---

A,B,C