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

Elegant way to split into sequences of identical chars?

by pKai (Priest)
on Nov 29, 2005 at 20:49 UTC ( #512768=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub seq1 {
        my $r;
    ...
        push @R, $r if length $r;
        @R;
    }
    
  2. or download this
    sub seq2 {
        my @x = shift =~ m/((.)\2*)/g;
        map $x[2*$_], 0..@x/2-1;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://512768]
Approved by Paladin
Front-paged by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2020-01-24 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?