sub rands{ my $t=0; $t = 0; $t+= ( rand()* ($_[0]/$_[1]) ) for(1..$_[1]); return int($t+1); } sub random{ my ($no,$type,$limit) = @_; $t = rands($no,5); if($type eq "low"){ while ($t<$limit){ $t = rands($no,5) } } elsif($type eq "high"){ while ($t>$limit){ $t = rands($no,5) } } }