Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Puzzlement in Splitsville

by tlm (Prior)
on Jun 19, 2005 at 12:43 UTC ( #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
Node Status?
node history
Node Type: perlmeditation [id://468106]
Approved by BrowserUk
Front-paged by grinder
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2018-07-16 01:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (330 votes). Check out past polls.

    Notices?