[Melbourne-pm] Nested maps returning hash references

Russell Jenkins rjenkins at rjj.id.au
Wed Oct 5 03:02:52 PDT 2011


On 5/10/11 5:42 PM, Toby Corkindale wrote:
> On 05/10/11 17:34, Alfie John wrote:
>>    - Andrew was right. Put a + in front of the block
> In case people want working test code, here is some below.
> By the way, I was trying to put the + on line 11 below, to no success, 
> but perhaps you mean a different {?
> (I'm picking the, umm, third that occurs in the whole program, or 
> second within the map..)
Hmmm, I think you need that unary + in front of the second '{' in your code.

i.e.
  ...
   +{ map { $f->can($_) ? ... } qw(label name html) }

At a quick guess, without flagging that this is an anon hashref, perl is 
treating this as a block, hence the 'flattened' output.

(Hope I'm not too sleep deprived to be on the right track..)
Cheers,
     Russell.




More information about the Melbourne-pm mailing list