perl -e '$p = 0;while ( ( $p = index( "AABAABBBB", "B", $p + 1 ) ) >= 0 ) { push @pos, $p + 1} print "@pos";'