map ++$array[rand $elements], 1..$sum; #### ++$array[rand $elements] for 1..$sum;