use strict; use warnings; while () { chomp; print join ' ', sort {$a<=> $b} map {/(\d+)-(\d+)/ ? $1 .. $2 : $_} split ','; print "\n"; } __DATA__ 18,5,1790,19-66,212,213