my %rhash = reverse %hash; my %fh; foreach my $num (keys %rhash) #### my @keys = keys %{{ reverse %hash }}; my %fh; foreach my $num ( @keys )