The sample code below on executing gives result as:- Macau Hong Kong But there are 0 keys in the hash. I expected the result to be Hong Kong Macau
Why is the hash getting empty here?
#!/usr/bin/perl
my %countries = ('+852' => 'Hong Kong', '+853' => 'Macau' );
my @string = {'+8521235567','+8531764458'} ;
while (my($prefix,$country) = each %countries)
{
$prefix = substr($string,1,3);
print "there are " . (keys %hash) . " keys in hash\n";
print $country."\n" ;
}
Thanks,
Mihir
