On 10 Aug., 00:58, [EMAIL PROTECTED] (Patrick R. Michaud) wrote: > On Fri, Aug 08, 2008 at 07:32:52AM +0200, Carl Mäsak wrote: > > Jonathan (>): > > > That this means the { $_ => uc $_; } above would end up composing a Hash > > > object (unless the semicolon is meant to throw a spanner in the > > > hash-composer works?) It says you can use sub to disambiguate, but > > > > %ret = map sub { $_ => uc $_; }, split "", $text; > > > > Doesn't work since $_ isn't an automatic parameter for a sub, like it > > > would > > > be in just a block (in the implementation, and if I understand correctly > > > in > > > the spec too). > > > Out of curiosity, would this work? > > > %ret = map -> { $_ => uc $_; }, split "", $text; > > A pointy block with nothing after the arrow is a sub with zero params, > so no, this wouldn't work. One would need something like > > %reg = map -> $_ { $_ => uc $_; }, split "", $text; > > > Or this? > > > %ret = map { $^foo => uc $^foo; }, split "", $text; > > I'm thinking S04 probably needs some clarification/updating here. > Any block that contains a (placeholder) parameter probably needs > to remain a sub, even if the block content is a comma-separated list > starting with a pair/hash.
But then, what will happen to this: %ret = map { { $^a => uc $^a } }, @arr; I would expect that to be the same as %ret = map -> $a { my %h={ $a => uc $a }; %h }, @arr; Regards, Ron