use Algorithm::Combinatorics qw(variations_with_repetition); my $iter = variations_with_repetition([ '0'..'9', 'a'..'z' ], 15); while($seq = $iter->next) { print @$seq,"\n"; last if ++$count > 50; }