Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by JavaFan (Canon)
on Feb 03, 2012 at 09:44 UTC ( #951629=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-28 09:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls