Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: substrings that consist of repeating characters

by tybalt89 (Prior)
on Sep 27, 2020 at 20:23 UTC ( #11122271=note: print w/replies, xml ) Need Help??


in reply to substrings that consist of repeating characters

TIMTOWTDI

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11122267 use warnings; my $string = "AAATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTATT +GGGGACTTT"; my @substrings; push @{ $substrings[length $1] }, $1 while $string =~ /(([ACTG])\2+)/g +; my @sorted = map @{ $_ // [] }, reverse @substrings; use Data::Dump 'dd'; dd \@sorted;

Outputs:

[ "CCCCCC", "GGGG", "AAA", "TTT", "TTT", "TTT", "TT", "TT", "AA", "GG", "GG", "TT", "AA", "TT", "TT", ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2020-10-25 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (249 votes). Check out past polls.

    Notices?