这会在Perl v5.20中引发错误:
use strict;
use warnings;
my @a = (2,3,9);
my %b = map { "number $_" => 2*$_ } @a;
Run Code Online (Sandbox Code Playgroud)
错误:
syntax error at a.pl line 4, near "} @a"
Execution of a.pl aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)
这不是:
use strict;
use warnings;
my @a = (2,3,9);
my %b = map { "number ".$_ => 2*$_ } @a;
Run Code Online (Sandbox Code Playgroud)
为什么$_在mapBLOCK 中不允许插值?