in reply to Seeking help from Perl Monks for counting regular expressions (motifs) and counting lengths between them in a large string

I'll leave the interaction with the environment to you.
$_ = "ATGCCCGATATATATCCCNNNATATATGCGCATGCTGCT"; say length $1 while /\G(.*?)AT/g; say length $'; __END__ 0 5 0 0 0 6 0 0 4 6
Or:
$_ = "ATGCCCGATATATATCCCNNNATATATGCGCATGCTGCT"; my ($l, $m) = (-2, 0); $m = length $', say -$l - 2 + ($l = length($`)) while /AT/g; say $m; __END__ 0 5 0 0 0 6 0 0 4 6
For those readers who get trigger happy when they see a use of $' or $`, feel free to use /p instead if you're going to use the above code.
  • Comment on Re: Seeking help from Perl Monks for counting regular expressions (motifs) and counting lengths between them in a large string
  • Select or Download Code