for my $trial (1..$max_trials) { my @attractors; for my $attractors (1..int(rand($max_attractor))+1) { my @attractor = get_random_tuple(3,\@attractor_limits); push @attractors, \@attractor; } my @grid_points; for my $points ($min_points..$max_points) { my @point = get_random_tuple(2,@grid_point_limits); # $alpha limits the distance moved downhill, and could be random @point = roll_down_hill(\@point, \@attractors, $alpha); push @grid_points, \@point; } my $result = analyze_data(\@grid_points); } sub get_random_tuple { my $size_of_tuple = shift; my $limits_ref = shift; my @tuple; for my $limit (@$limits_ref) { push @tuple, rand($limit); } return @tuple; } sub roll_down_hill { # left as an exercise for OMAR! }