[Melbourne-pm] Nested maps returning hash references
Toby Corkindale
toby.corkindale at strategicdata.com.au
Tue Oct 4 22:52:49 PDT 2011
On 05/10/11 16:51, Andrew Pam wrote:
> On 05/10/11 16:46, Andrew Pam wrote:
>>> map {
>>> my $f = $_;
>>> {
>>> map {
>>> $f->can($_) ? ($_ => $f->$_) : ()
>>> } qw(label name html);
>>> }
>>> } @fields;
>>>
>>>
>>> Any thoughts?
>>
>> Actually looking more closely, the braces around the inner map in the
>> final example look like they're being interpreted as a block, not as an
>> anonymous hash constructor.
>
> Note: Putting a unary "+" in front of the open bracket should turn it
> into an unambiguous hash constructor.
That was one of the first things I tried after reading the map
function's documentation - it doesn't work - not valid syntax.
More information about the Melbourne-pm
mailing list