use Parse::RandGen; my $p = Parse::RandGen::Regexp->new(qr/a(b|c)d?/); print $p->pick for 1 ..5 __output__ abd ab ac acd abd