I changed $lengthRemaining to $n after successfully testing the script, to better fit the pod statement, and forgot to update the if statement: sub makeDNA { my $n = shift; my @alphabet = qw( A C G T); if ($n == 0) { return; } print $alphabet[int(rand(4))]; makeDNA($n - 1); }