Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://147981]
[Corion]: Whoops - more spam - I guess I'll have to collate a list and have them banned later today
[Corion]: Maybe I should bring my Github credentials to $work some day, just to open issues for ;)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-02-24 11:49 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (354 votes). Check out past polls.