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

Re: Puzzlement in Splitsville

by eyepopslikeamosquito (Chancellor)
on Jun 19, 2005 at 14:30 UTC ( #468139=note: print w/replies, xml ) Need Help??


in reply to Puzzlement in Splitsville

thundergnat's solution is the best I can see (I came up with it independently) because it avoids the ugly removal of every 2nd item. However, because variety is the spice of life I present the ganglier:

my @runs = do { my $i; grep ++$i%2, split /(?<=(.))(?!\1)/, 'aaabbcddd +daee' };
which suffers from the same annoyance as your original solution: the parens, which are needed for the back reference, have the annoying side effect here of changing the semantics of what split returns.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://468139]
help
Chatterbox?
[marto]: good morning all
[Corion]: Hi marto ;)
[Corion]: I hope you're well ;)
[marto]: running late today, get to work and people are just sitting around. "can't delete file, quota exceeded"
[Corion]: marto: Oy :-/
[Corion]: Ah, it's only "quota exceeded", not "filesystem full", so it's "merely" an administrative act to up the FS quota resp. inode quota
[Corion]: I've been on databases where I couldn't drop a table or delete rows because the DB was full. Not so much fun...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-01-24 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (203 votes). Check out past polls.