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

Re: Puzzlement in Splitsville

by eyepopslikeamosquito (Archbishop)
on Jun 19, 2005 at 14:30 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://468139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found