How can I get ranges from a list of integers in Perl?
- by Suezy
I have an array of numbers:
@numbers = 1,2,3,6,8,9,11,12,13,14,15,20
and I want to print it this way:
1-3,6,8-9,11-15,20
Any thoughts? Of course I tried using the most common "looping", but still didn't get it.