Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Puzzlement in Splitsville

by tlm (Prior)
on Jun 19, 2005 at 12:43 UTC ( [id://468106]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    atgactaatagcagtgg
    
  2. or download this
    0 'atg'
    1 'act'
    ...
    3 'agc'
    4 'agt'
    5 'gg'
    
  3. or download this
    @codons = grep $_, split /(.{3})/, 'atgactaatagcagtgg';
    print "@codons\n";
    __END__
    atg act aat agc agt gg
    
  4. or download this
    @codons0 = split /(?:.{3})/, 'atgactaatagcagtgg';  # disable capture w
    +ith ?:
    @codons1 = split /.{3}/,     'atgactaatagcagtgg';  # no parens
    ...
    __END__
    ::::::gg
    ::::::gg
    
  5. or download this
    @codons = 'atgactaatagcagtgg' =~ /.{1,3}/g;
    print "@codons\n";
    __END__
    atg act aat agc agt gg
    
  6. or download this
    @codons = 'atgactaatagcagtgg' =~ /.{3}/g;
    print "@codons\n";
    __END__
    atg act aat agc agt
    
  7. or download this
    @parts = '12abc3ef' =~ /[a-z]+|\d+/g;
    print "@parts\n";
    __END__
    12 abc 3 ef
    
  8. or download this
    @parts = grep $_, split /([a-z]+|\d+)/, '12abc3ef';
    
  9. or download this
    @parts = split /(?<=[a-z])(?=\d)|(?<=\d)(?=[a-z])/, '12abc3ef';
    
  10. or download this
    0 'aaa'
    1 'bb'
    ...
    3 'dddd'
    4 'a'
    5 'ee'
    
  11. or download this
    @runs = do { my $i; grep ++$i%2, 'aaabbcddddaee' =~ /((.)\2*)/g };
    print "@runs\n";
    __END__
    aaa bb c dddd a ee
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://468106]
Approved by BrowserUk
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-23 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found