哈希我想使用哈希像这样的哈希 -哈希在Perl
#!/usr/bin/perl -w
use strict;
my %hash =();
sub hash_populate
{
my $name = "PQR,ABD,XYZ";
my @parts = split(/,/,$name);
my $i = $parts[0];
my $a= $parts[1];
my $b = $parts[2];
$hash{$i} = {"A" =>$a,"B" => $b};
my $c = $hash{$i}{"A"};
print $c;
}
我得到以下形式的错误
Can't use string ("HASH(0x16c43c)") as a HASH ref while "strict refs" in use
相同的代码工作时use strict
不存在。有人能告诉我为什么吗?
随着v5.10.1,上面的代码运行没有错误。 – 2010-06-29 15:51:04
@diyars:请显示您如何调用'hash_populate'以及错误的行号。 – toolic 2010-06-29 15:57:12
使用perl v.5.8.9它也运行没有错误。 – GorillaPatch 2010-06-29 15:59:11