Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: substrings that consist of repeating characters

by BillKSmith (Monsignor)
on Sep 28, 2020 at 22:38 UTC ( [id://11122309]=note: print w/replies, xml ) Need Help??


in reply to Re: substrings that consist of repeating characters
in thread substrings that consist of repeating characters

A slight simplification can be gained by using the 'nsort_by' function from List::UtilsBy (or its XS equivalent). You can also use the special variable '$,' rather than 'join' to control the print.
use strict; use warnings; use List::UtilsBy::XS qw(nsort_by); my $string = "AAATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTATT +GGGGACTTT"; my @matches; push @matches, $& while ($string=~m/([AGCT])\1+/g); local $, = "\n"; print nsort_by {length} @matches ;
Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 11:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found