Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-08-28 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls