#!/usr/bin/perl use strict; use warnings; use Set::IntSpan; my @arr = (19,17,22,23,24,15,16,25..35); my $set = Set::IntSpan->new(\@arr); print join ' ', $set->holes->elements;