{ 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:So you need to help Perl doing the right guess, using a plus sign (and parentheses!):
use warnings; use strict; @_ = 'a' .. 'c'; print @_[ map +($_ -1), grep { $_ > 0 and $_ <= 1 } map { $_ + 1 } -1..1 ];
In reply to Re: [closed] map sentence as array slice indexes
by Discipulus
in thread [closed] map sentence as array slice indexes
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |