小编jlo*_*ren的帖子

为什么在`map` BLOCK中没有插值?

这会在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 中不允许插值?

perl perl-data-structures

9
推荐指数
1
解决办法
103
查看次数

标签 统计

perl ×1

perl-data-structures ×1