#!/usr/bin/perl -w use strict; my $Min=0; my $Max=100; my $Count=50; my $Average=50; my $RealAverage=0; my $Total=0; my @Result; for(1..$Count) { #my $New=int(rand($Max/2)+$Min+(($RealAverage>$Average)||$Average)); # Sorry, this line was totally screwed up, as it would # give results outside the bounds given, substitute by # this: my $New=int(rand($Max-$Min))+$Min; $New+=$Average if ((($New+$Average)<$Max)&&($RealAverage<$Average)); $New-=$Average if ((($New-$Average)>$Min)&&($RealAverage>$Average)); $Total+=$New; $RealAverage=$Total/$_; push @Result,$New; }; print join "\n",@Result; print "\nAverage: $RealAverage\n";