in reply to what's wrong with that syntax construction?
Without the parens, the first 'rand' is taken as a string; and that causes the parser to see { 'rand' => rand } as an anomymous hash.
With the parens, it parses { rand() => rand } as an anonymous block as you intend.
You can also force the parser to see the anonymous block like this: my @x = map {; rand => rand } (0 .. 5);.
The extra semicolon is legal inside an anonymous block, but not in an anonymous hash, so the parser gives the benefit of the doubt and goes the way you intend.
|
|---|