basiliscos has asked for the wisdom of the Perl Monks concerning the following question:
I would like to generate random hash, i.e. where key is random number and value is also random number
my @x = map { rand => rand } (0 .. 5) Compile error: syntax error at (eval 310) line 5, near "} (" BEGIN not safe after errors--compilation aborted at (eval 310) line 5.
Mean while, the following works:
my @x = map { rand() => rand } (0 .. 5);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what's wrong with that syntax construction?
by BrowserUk (Patriarch) on Jun 15, 2016 at 13:31 UTC | |
|
Re: what's wrong with that syntax construction?
by Athanasius (Cardinal) on Jun 15, 2016 at 13:31 UTC | |
|
Re: what's wrong with that syntax construction?
by Eily (Monsignor) on Jun 15, 2016 at 13:33 UTC |