my @range_destination = ( [ 1.0, 1.4, 1 ], [ 1.4, 1.9, 2 ], ... [ 99.2, 99.8, 99 ], [100.1, 100.9, 100 ], ); # what you call $val is really a KEY, # but I'll keep your name anyway. while ( my ( $val, $real_val ) = each %netHash ) { CONDITION: foreach my $cond_ref ( @range_destination ) { my ( $min, $max, $dest ) = @$cond_ref; if ( $val > $min && $val < $max ) { $capVal_Hash{$dest}{$val} = $real_val; last CONDITION; } } }