in reply to grouping consecutive integers
artistuse Set::IntSpan; use strict; sub consecutive_integers_list { my(@integers) =sort { $a <=> $b } @{+shift}; my $set = Set::IntSpan->new(join ",", @integers); $set->run_list; } my @integers = qw( 20 2 3 4 5 6 7 23 19 17 25 30 11 12 22 21 68 103829 + 24 18 ); print consecutive_integers_list(\@integers); #prints: 2-7,11-12,17-25,30,68,103829
|
|---|