#!/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;
In reply to Re^3: Convert an array of numbers into a range
by Anonymous Monk
in thread Convert an array of numbers into a range
by rmocster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |