my @foo = qw(just another perl monkey);
my $x = 0;
print join("\n",map { $x++ . ": $_" } @foo);
The output is:
0: just 1: another 2: perl 3: monkeyIf you don't know how to use map() then learn, it makes doing large operations on hashes or arrays brutally simple.