$allseq="ctaacjkjfggctaatlkj"; $len=3; while($allseq =~ /(ct(?:a|g)a(?:c|t))(?:.{$len})/g) {push(@array, $1);} print join("-",@array)."\n";