#!/usr/bin/perl use strict; use List::Util qw(shuffle); use Data::Dumper; #undef $/; #$/=''; my %ac=(); my @l=1..20; print join(",",shuffle(@l)); for (1..1000){ my ($a,$b)= _choice( @{[20..(int(rand(10))>8 ? 40 : 30)]} ) ; $ac{$b}++; print "Res: $a / $b\n" } print Dumper(\%ac); sub _choice{ my @a=@_; my $i = int(rand(scalar @a)); ($a[$i], $i)}