Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

/prakash

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2014-07-11 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (228 votes), past polls