Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 chanting in the Monastery: (4)
As of 2015-07-06 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls