【发布时间】:2014-01-09 22:39:42
【问题描述】:
这是我不明白的地方。
这个脚本可以正常工作(注意 map functin 中的连接):
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %aa = map { 'a' . '' => 1 } (1..3);
print Dumper \%aa;
__END__
output:
$VAR1 = {
'a' => 1
};
但是如果没有连接,地图就无法工作。这是我希望工作的脚本,但它没有:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %aa = map { 'a' => 1 } (1..3);
print Dumper \%aa;
__END__
output:
Not enough arguments for map at e.pl line 7, near "} ("
syntax error at e.pl line 7, near "} ("
Global symbol "%aa" requires explicit package name at e.pl line 9.
Execution of e.pl aborted due to compilation errors.
你能解释一下这种行为吗?
【问题讨论】:
标签: perl dictionary