我想创建一个哈希数组,我想知道如何引用数组中的每个哈希?Perl的哈希数组 - 引用数组中的每个哈希值?
对于如:
while(<INFILE>)
{
my $row = $_;
chomp $row;
my @cols = split(/\t/,$row);
my $key = $cols[0]."\t".$cols[1];
my @total =(); ## This is my array of hashes - wrong syntax???
for($i=2;$i<@cols;$i++)
{
$total[$c++]{$key} += $cols[$i];
}
}
close INFILE;
foreach (sort keys %total) #sort keys for one of the hashes within the array - wrong syntax???
{
print $_."\t".$total[0]{$_}."\n";
}
预先感谢任何帮助。
在这个逻辑是比一个解决哈希和数组的使用有点更多的破碎。也许你可以解释你想要达到的目标,并且我们可以指出你朝着正确的方向。 – chambwez 2011-03-30 21:34:01
http://perlmonks.org/?node=References+quick+reference可以非常有帮助 – ysth 2011-03-30 23:05:42