Hi,

There is in the spectests this example:

my $text  = "abc";
my %ret;
%ret = map { $_ => uc $_; }, split "", $text;
is ~%ret.kv, "a A b B c C", "=> works in a map block";

However, it seems from S06:

"|{...}| is always a block. However, if it is completely empty or consists of a single list, the first element of which is either a hash or a pair, it is executed immediately to compose a Hash object."

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).

%ret = map sub { $^a => uc $^a; }, split "", $text;

Will work, of course... But anyway, I guess either of:

* The test is wrong to expect to have that parsed as a block
* The semicolon disambiguates it - I don't see any suggestion of that in the spec, though, so if it's the case a note on this would be helpful

Thanks,

Jonathan

Reply via email to