my @num = 0..9; my %res; for ( 1 .. 1_000_000 ) { $res{ $num[ rand @num ] }++; } print "Test 1:\n"; print "$_ => $res{$_}\n" for @num; print "\n"; %res = (); for ( 1 .. 1_000_000 ) { $res{ int( rand($#num) + 0.5 ) }++; } print "Test 2:\n"; print "$_ => $res{$_}\n" for @num;