Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Generating ranges of numbers

by Anonymous Monk
on Jun 30, 2016 at 13:43 UTC ( [id://1166925]=note: print w/replies, xml ) Need Help??


in reply to Generating ranges of numbers

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1166921 use strict; use warnings; my @array = ("1","2","3","5","6","7","9"); my @ranges = split ' ', "@array" =~ s/\b(\d+)\K (?=(\d+)(??{$1 != $2 - 1 && 'fail' }))/:/gr =~ s/:[\d:]+:/:/gr; print "@ranges";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found