#!/usr/bin/perl use strict; use warnings; use Set::IntSpan; use Set::CrossProduct; while () { my @set; if (/^\d+$/) { print; } else { chomp; s/\./[0-9]/g; for my $part (split /(\[.+?])/) { if (-1 == index $part, '[') { push @set, [$part]; } else { my $set = Set::IntSpan->new( substr $part, 1,-1 ); push @set, [ $set->elements() ]; } } my $xp = Set::CrossProduct->new( \@set ); while( my @tuple = $xp->get ) { print @tuple, "\n"; } } } __DATA__ 1115551234 111555124. 111555125[0,3-7]