Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: syntax error with map in list context

by dave0 (Friar)
on Nov 20, 2005 at 13:38 UTC ( #510244=note: print w/replies, xml ) Need Help??

in reply to syntax error with map in list context

It's a known issue with Perl guessing wrong on the meaning of the initial {. See the Perldoc for map, in the paragraph beginning:

"{" starts both hash references and blocks, so "map { ..." could be either the start of map BLOCK LIST or map EXPR, LIST.

There are examples of how to avoid the problem in that doc, but my suggestion would be:

my %data = map +( "Player number $_" => [ map { 1 + int rand(10) } 1 .. 5 ] ), 1 .. 10;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://510244]
Discipulus now is read a book to my daugther time. Just after she and mother stop yelling in the bathroom
[Lady_Aleena]: See you later, Discipulus. Have fun reading to your daughter.
Discipulus still yelling..;=(

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-09-24 18:31 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (274 votes). Check out past polls.