use Parse::Range qw(parse_range); my $w='1 3-6 9-13'; print $w,"\n"; $w=~s/\s+/,/; print $w,"\n"; my @range=parse_range($w); print @range, "\n"; print $range[2];