in reply to Breaking Up a Bracketed String

Feeling a bit ashamed of having come up with a cruder and less flexible solution than Aristotle's fine example above, I dare show it anyway. Most notable drawback of this is its expectation of the ocurrence of only one single pair of brackets.

$str1 = q/ATC[TG]CC/; $ans_of_str2 = all_ans( $str1 ); sub all_ans { my @results; my ( $pre, $multi, $post ) = split /\[(.*)\]/, $_[0]; if ( $multi ) { my @chars = split //, $multi; for ( @chars ) { push @results, "${pre}${_}$post" } return [ @results ]; } return [ $_[0] ]; }

Cheers, Sören