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

Re: Question on s///eg

by PrakashK (Pilgrim)
on Feb 27, 2002 at 17:27 UTC ( #147981=note: print w/ replies, xml ) Need Help??

in reply to Question on s///eg

Here's some not so thouroughly tested code:

my @channels = (1, 1, 0, 1, 1, 1, 0); my $str = join "", @channels; my @range; push @range, join "-", ($-[0], $+[0]-1) while $str =~ m/(1+)/g; print join ",", @range;
prints 0-1,3-5


Update: I must add that this may not work for perl versions older than 5.6.0.

Comment on Re: Question on s///eg
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://147981]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-11-25 05:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (670 votes), past polls