[Melbourne-pm] Nested maps returning hash references
Andrew Pam
andrew at sericyb.com.au
Tue Oct 4 22:46:28 PDT 2011
On 05/10/11 16:34, Toby Corkindale wrote:
> OK, this is doing my head in.
>
> I have two map functions that work perfectly well on their own:
>
> map {
> $f->can($_) ? ($_ => $f->$_) : ()
> } qw (label name html);
>
> map {
> {
> label => $f->label,
> name => $f->name,
> html => $f->html,
> }
> } @fields;
>
>
> However when I combine them, it all goes pear-shaped, and I just get
> back one huge, flat array, rather than an array of hashes.
>
> 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.
Hope that helps,
Andrew
--
Andrew Pam <andrew at sericyb.com.au>
Serious Cybernetics
More information about the Melbourne-pm
mailing list