my $children = $distribution[rand(@distribution)]; # instead of my $children = int(rand(6));