in reply to Generating mulitple random strings of a set length

I don't understand what your code is trying to do or why you talk about "replacements," but if you want to get a random substring from a longer string, why not just pick a random offset between 0 and the difference between the full string's length and the substring's length? Here's an iterator which does that:

#!/usr/bin/env perl use 5.010; use warnings; use strict; my $DNA = "AACCGTTAATGGGCATCGATGCTATGCGAGCT"; sub make_rand_getter { my $s = shift; my $sl = length $s; return sub { return substr $s, int rand($sl - $_[0]), $_[0]; } } my $rstring = make_rand_getter($DNA); say "3-letter string: " . $rstring ->(3); say "7-letter string: " . $rstring ->(7);

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.