Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Convert an array of numbers into a range

by Anonymous Monk
on Jul 22, 2016 at 00:37 UTC ( [id://1168293]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Convert an array of numbers into a range
in thread Convert an array of numbers into a range

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1168288 use strict; use warnings; my @ra = qw(0001 0002 0003 011 012 013 015 16 17 18 20); print join(',', @ra) =~ s/\b(\d+)(?{$1})\K(?:,(\d+)\b(??{++$^R!=$2}))+ +/-$2/gr;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-16 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found