in reply to Trying to construct all possible strings from 4 bases [ATCG]

You didn't say in what way the code is behaving differently from your expectation but it's a fairly simple problem to solve correctly; even without recursion.

#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my $length = 2; my @motif = ( '' ); for my $i ( 1 .. $length ) { @motif = map { my $motif = $_; map $motif . $_, qw( a t c g ); } @motif; } print Dumper \@motif;

Ie we start out with a list with a single empty string and then on each round, we create four new strings for every string we already have.

(The shard-eyed will notice that this code does the same work as the recursive variant, only explicitly — well, and in different order.)

Makeshifts last the longest.