my @n = qw(16 107 108 110 112 114 115 117 118 119 120 121 122 123 124 125 127 128 130 132 133 135 136 138 142 146 149 150 154 156 157 158 159 161 162); my $set = Set::IntSpan::Fast->new; $set->add(@n); print $set->as_string, "\n"; __END__ 16,107-108,110,112,114-115,117-125,127-128,130,132-133,135-136,138,142,146,149-150,154,156-159,161-162