Recommended reading which deals with variations on this problem at length:
Calendrical Calculations section 1.12, "Cycles of Years".
Distributing m (here, $num) "evenly" into n (here, scalar(@array)) elements,
some will be int(m/n), and m%n will be 1 more than that.
So, putting all the extras at the front gives:
my %result;
my $num = 13;
my @array = qw(a b c d e);
@result{@array} = map int($num/@array) + $_ < $num%@array, 0..$#array;
To do it randomly, use
@result{shuffle @array} instead.
Spreading them out as evenly as possible gives:
@result{@array} =
map int($num/@array) + ($_ * ($num%@array) % @array < $num%@array),
0..$#array;
(See formula 1.57 in the book.)