{ my $r = substr rand, 2; sub crand() { length $r or $r = substr rand, 2; chop $r; } } s[(.)]{$1 x (1+crand/3)}ge;