It's also worth noting that it can modify your original array in place

@a = ('bob','jane');
map {$_ = ucfirst($_)} @a;

This can be useful (or painful if you forget about it).

George

On Sunday, November 24, 2002, at 01:04 PM, Paul Johnson wrote:

On Sun, Nov 24, 2002 at 12:13:55PM -0500, Tanton Gibbs wrote:

So, the purpose of map is to change every element of an array in the same
way and create a new array with those changed elements.
Quite.  Whenever you need to create an list by performing an operation
on every element of another list, think C<map>.

But map can also do more.  For each element of your original list you
can create zero, one or more elements in the result.

$ perl -le 'print map { ($_) x $_ } (0 .. 3)'
122333

--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to