#!/usr/bin/perl use strict; use warnings; use Set::IntSpan; my @array = ("1", "2", "3", "5", "6", "7", "9"); my $set = Set::IntSpan->new(\@array); my $out = join(',', $set->D($set->holes())); print $out, "\n"; #### OUTPUT: 1-3,5-7,9