use Set::IntSpan; my $set = Set::IntSpan->new('3-12,25-30,42'); for ( my $el=$set->first; defined $el; $el=$set->next ) { print "$el\n"; }