On 11/07/2015 10:17 AM, Marc Chantreux wrote: > hello Moritz, > > On Sat, Nov 07, 2015 at 08:17:21AM +0100, Moritz Lenz wrote: >> my %x = < login jdoe first john last doe >; >> my %y = flat (:enable, %x< login first >:p); > > i tried :p but the thing is i was searching for something straight as > the perl5 > > my %y = (%x, qw( enable 1 )); > > si i really loved > > my %x = < login jdoe first john last doe >; > my %y = ( :enable, %x< login first >:p); > > to work. thanks for showing me this working code. > > actually, it rises a new question to me: why the parenthesis around > flat are mandatory? > > my %x = < login jdoe first john last doe >; > my %y = flat (:enable, %x< login first >:p); > > is ok but > > my %x = < login jdoe first john last doe >; > my %y = flat :enable, %x< login first >:p; > > give me > >> first => john, last => doe, login => jdoe >> Unexpected named parameter 'enable' passed
Because some of the pair literal syntaxes (:enable, :enable(1), enable => 1, but for example not "enable" => 1) are also used for named arguments, and sub flat doesn't want a named argument. Putting the parens around it force it not be a named argument. Cheers, Moritz