in reply to So close...

Your code is quite hard to read, partly because you name the variables after the kind of data structure they hold. It is easier to read if you name them according to what they mean.

When I execute your code, I get warnings like this:

splice() offset past end of array at foo.pl line 146. splice() offset past end of array at foo.pl line 147. splice() offset past end of array at foo.pl line 158.
(line numbers may differ from yours a bit).

It basically means that you try to delete an array element that doesn't exist. Which means that at some point the logic that calculates the index $removed is incorrect.

Maybe you could just write a few lines of comment to each function to describe in your own words what it should do, then we can compare that to what it does.

A few suggestions regarding your code:

sub makeArrays { $lower = 10; $upper = 20; my @chroma; my @chromb; my $ranpop; $ranpop = int rand($upper - $lower + 1) + $lower; # @arrA and @arrD hold the same values, and # aren't modified - why do you need them both? # what is their purpose? my @arrA = ( 1 .. $ranpop ); my @arrD = (1 .. $ranpop ); my $limiter = 50; # you can write that shorter: # my @holda = map { int rand($limiter)} 1 .. $randpop; # my @holdb = map { int rand($limiter)} 1 .. $randpop; my @holda; my @holdb; while ($ranpop) { my $genea = int rand ($limiter); push(@holda, $genea); my $geneb = int rand ($limiter); push(@holdb, $geneb); $ranpop--; } # there's no need to copy these arrays # you can return \@holda and \@holdb directly. my @arrB = ( @holda ); my @arrC = ( @holdb ); return \@arrA, \@arrB, \@arrC, \@arrD; }

You tend to create way too many unnecessary variables that do nothing but clutter up your code (and possibly slow it down):

my $childa = $dada; my $childb = $momb; push @chroma, $childa; push @chromb, $childb;
you can write that as
push @chroma, $dada; push @chromb, $momb;