> -----Original Message-----
> From: Paul [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 01, 2001 3:41 PM
> To: Bob Showalter; '[EMAIL PROTECTED]'
> Subject: RE: check array element (HELP)
> 
> 
> 
> --- 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)

Yes, you are correct. The curlies in the map() are a block. Context
is everything.

> 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.

Actually the { } around map creates the hash ref, while the outer %{ }
dereferences this hash ref back to a hash, so I can feed it to keys(). 
Just one pair of {} doesn't do it.

Whew!

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

Reply via email to