--- Bob Showalter <[EMAIL PROTECTED]> wrote:
> . . .
> Yep, you've got it. Actually map() is creating a *list*, which is
> being used to initalize an anonymous hash. Working from the inside
> out:
>
> map { ($_ => 1) } @arr
>
> returns a list equivalent to ($arr[0], 1, $arr[1], 1, $arr[2], 1,
> ...).
> Wrapping any list in curly braces:
>
> { list }
>
> returns a reference to an anonymous hash initialized from the list.
Just a caution -- I misread this the first time through. =o)
While generally true, consider the context. For example,
map { ($_ => 1) } @arr
is wrapping a list in curly braces, but in this case, it's a block.
The curlies represent not a hash reference, but code block which map
uses. The code is just a list expression.
Curlies do return hash refs, though, in the right context. =o)
What was the code? something like
%{ { map { ($_ => 1) } @arr } }
The %{} says "the enclosed expression evaluates to a hash reference".
The inner curlies make the reference out of the list.
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]