From map:
{ starts both hash references and blocks, so map { ... could be either the start of map BLOCK LIST or map EXPR, LIST. Because Perl doesn't look ahead for the closing } it has to take a guess at which it's dealing with based on what it finds just after the {. Usually it gets it right, but if it doesn't it won't realize something is wrong until it gets to the } and encounters the missing (or unexpected) comma. The syntax error will be reported close to the }, but you'll need to change something near the { such as using a unary + or semicolon to give Perl some help:
$ perl -wMstrict -le 'print map { (2, $_) } 1 .. 2' 2122 $ perl -wMstrict -le 'print map {; 2, $_ } 1 .. 2' 2122 $ perl -wMstrict -le 'print map { +2, $_ } 1 .. 2' 2122
In reply to Re: strange syntax error with map
by haukex
in thread strange syntax error with map
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |