in reply to Ahh the map function
map BLOCK LIST map EXPR,LIST Evaluates the BLOCK or EXPR for each element of LIST (locally setting "$_" to each element) and returns the list value composed of the results of each such evaluation. In scalar context, returns the total number of elements so generated. Evalu ates BLOCK or EXPR in list context, so each ele ment of LIST may produce zero, one, or more ele ments in the returned value. @chars = map(chr, @nums); translates a list of numbers to the corresponding characters. And %hash = map { getkey($_) => $_ } @array; is just a funny way to write %hash = (); foreach $_ (@array) { $hash{getkey($_)} = $_; }
So, for each element in @edittypes (let's say $_ = 'foo'), it would spit out \.foo. The return value from map would be a list of these transformed elements.
Update: Corrected escaping of backslash.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Ahh the map function
by Anonymous Monk on Jul 07, 2002 at 04:16 UTC | |
by DamnDirtyApe (Curate) on Jul 07, 2002 at 04:25 UTC | |
| |
|