in reply to what's wrong with that syntax construction?
In this case it's a good thing you get a syntax error because if it did compile it wouldn't do what you want. The fat comma (=>) forces its left side to be interpreted as a bareword, so a string most of the time*. So the left side of rand => rand is "rand". Somehow, seeing something that can only be a bareword after the { confuses perl into parsing the construct incorrectly.
* print rand =>; is parsed as print(rand, $_);, not print(rand()); and not print("rand"); either.
Edit: as pointed out by BrowserUK and Athanasius, here the bareword is interpreted as a string, which makes the code look like an anonymous hashref.
|
|---|