my $num_of_rounds = 5; while($num_of_rounds--) { my %nums = (); for (0..24) { my $n = 0; while(1) { $n = int(rand(25)); last unless exists $nums{$n}; } $nums{$n} = 1; print "$n\t"; } print "\n"; }