http://www.perlmonks.org?node_id=510234

LucaPette has asked for the wisdom of the Perl Monks concerning the following question:

I have written the following code:
#!/usr/bin/perl -w use strict; my %data=map { "Player number $_", [ map { 1 + int rand(10) } 1 .. 5 ] } 1 .. 10; print "$_ @{$data{$_}}\n" for ( keys %data );
It doesn't work, infact perl prints an error like this:
syntax error at ./mytest line 9, near "} 1" Execution of ./mytest aborted due to compilation errors.
To resolve the problem i have changed this chuck of code:
my %data=map { "Player number $_", [ map { 1 + int rand(10) } 1 .. 5 ] } 1 .. 10;
with this:
my %data=map { "Player number " . $_, [ map { 1 + int rand(10) } 1 .. 5 ] } 1 .. 10;

With the latter chuck of code the little program works and prints an output like this:

Player number6 6 7 3 2 7 Player number2 3 2 6 7 8 Player number7 1 7 3 7 1 Player number1 8 10 4 7 4 Player number10 1 2 5 1 3 Player number9 1 4 10 4 8 Player number4 4 1 4 5 5 Player number3 8 6 9 5 6 Player number5 9 3 5 6 6 Player number8 10 3 8 8 1
Now i am wondering which is the problem with the former code but i am not be
able to find an answer.
Can someone help me to find the right answer?