On Fri, Apr 20, 2018 at 01:25:49PM -0700, via RT wrote: > # New Ticket Created by > # Please include the string: [perl #133134] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=133134 > > > > > This is a bug report for perl from jim.avera@gmail.com, > generated with the help of perlbug 1.40 running under perl 5.26.1. > > ----------------------------------------------------------------- > If used inside map{...}, the construct > > { %+ } > > results in a flat list of keys and values, not a ref to a hash. An '{' at the start of a statement is ambiguous: it could be the start of a new block, or the start of a hash constructor. In this situation, perl makes an educated guess based on the first few characters following the '{'. In this case, its guess didn't match your hopes. You can avoid the ambiguity by providing perl with more information; for example: %a = qw(a 1 b 2); sub f1 { 1; { %a } } # ambiguous sub f2 { 1; scalar { %a } } # unambiguous: a hash ref constructor sub f3 { 1; {1; %a } } # unambiguous: a block print ((f1())[0], "\n"); print ((f2())[0], "\n"); print ((f3())[0], "\n"); which outputs: a HASH(0x22314e8) a -- "I used to be with it, but then they changed what ‘it’ was, and now what I’m with isn’t it. And what’s ‘it’ seems weird and scary to me." -- Grandpa Simpson (It will happen to you too.)Thread Previous | Thread Next