Yes you are allowed to use my there, it is not a syntax error! And using it there produces a variable that is in the same scope as map is in. It is just that the value of the variable created is not defined by the Perl language. Compare the different error messages:
$ perl -wle'use strict; map +(my $x = $_), 2; print $x' Use of uninitialized value $x in print at -e line 1. $ perl -wle'use strict; { map +(my $x = $_), 2; } print $x' Global symbol "$x" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.
In reply to Re^7: syntax of map operator
by jwkrahn
in thread syntax of map operator
by sman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |