mpeters has asked for the wisdom of the Perl Monks concerning the following question:
But thismy %hash = map { $_ => "stuff_$_" } qw(asdf qwert zxcv);
results in a syntax error (syntax error ... near "} qw(asdf qwert zxcv)")my %hash = map { "stuff_$_" => $_ } qw(asdf qwert zxcv);
Back in my day we used 'foreach' and we liked it!
would easily tell the parser it's an anon-hash. So anything with a '{' is a block until otherwise told it is not.my %hash = map { {"stuff_$_" => $_} } qw(asdf qwert zxcv);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: order in map
by NetWallah (Canon) on May 02, 2005 at 19:45 UTC | |
by suaveant (Parson) on May 02, 2005 at 19:48 UTC | |
|
Re: order in map
by ryantate (Friar) on May 02, 2005 at 20:36 UTC | |
by Anonymous Monk on May 04, 2005 at 15:46 UTC | |
by ryantate (Friar) on May 04, 2005 at 17:05 UTC | |
|
Re: order in map
by osunderdog (Deacon) on May 02, 2005 at 19:54 UTC | |
by ysth (Canon) on May 02, 2005 at 20:02 UTC | |
|
Re: order in map
by suaveant (Parson) on May 04, 2005 at 15:12 UTC |