我想一一遍历HASH。不是随机方式。任何的想法。例如我有这样的哈希文件......
our %HASH = (
'rajesh:1700' => Bangalore,
'rajesh:1730' => Delhi,
'rajesh:1770' => Ranchi,
'rajesh:1780' => Mumbai,
'rajesh:1800' => MYCITY,
'rajesh:1810' => XCF,
);
它应该以相同的方式打印。我尝试了以下但失败了。有任何想法吗?
while ( my $gPort = each %HASH)
{
print "$gPort\n";
}
for my $gPort ( keys %HASH )
{
print "$gPort\n";
}