in reply to Howto Dynamically Create a Hash?

You show more keys than numbers. This only warns if there are not enough keys.
my @nlist = (3,24,8,17,23,14,17,9,16,24,25,11,22,14,14,8,19,16,15,8); my @key_list = ('A'..'D'); my ($result, @ans, $i) ; for my $num ( @nlist ) { $i = 0; while ( 1 ) { if ( ! defined @{$ans[$i]} or 0 == $num % ${$ans[$i]}[0] ){ push @{$ans[$i]}, $num; last; } ++$i; } } $result->{ shift @key_list } = $_ for @ans ;
Be well,
rir