in reply to Breaking Up a Bracketed String

And another solution, using map...
my $string = "ATCGC[ATCG]AAA[GA]"; my @out = ($string =~ m/([^\[]*)/)[0]; while ($string =~ m/\[(\w+)\]/g) { @out = map {my $char=$_;map {$_.$char} @out} split//,$1; } print join("\n", @out) . "\n";

Hmmm, that missed the AAA's on the output (thanks Roy Johnson)

Here's another one just for fun :)

my $string = "ATCGC[ATCG]AAA[GA]"; my @out = ""; $string=~s!([^\[]*)(\[([^\[]*)\])?!@out=map{my$c=$_;map{$_.$1.$c}@out} +split'',$3if$1or$3!ge; print join("\n", @out) . "\n";
---
my name's not Keith, and I'm not reasonable.