use Modern::Perl; use Parse::Range qw(parse_range); say join ' ', sort {$a <=> $b} parse_range('1-2a,27,150b-170,51d2,670-675, 12, 90-97, 99-95');