chomp($line); my ($state,$min,$max) = split /,/,$line; foreach my $current_zipcode ( keys %zip_city ) { if ( $current_zipcode >= $min and $current_zipcode <= $max ) { $zip_city_state{$current_zipcode}{city} = $zip_city{$current_zipcode}; $zip_city_state{$current_zipcode}{state} = $state; delete $zip_city{$current_zipcode}; } }