in reply to randomizing global replacement
Have you looked closely at the modifiers after each substitution? For example, add an "e" to option 1.
$a =~ s/a/$a[int(rand(@a))]/ge;
Or, perhaps better yet, take it away from option 2.
$b =~ s/b/randme()/g;
Result:
option 1: heebdjfjiecbieiebdfddi option 2: randme()randme()randme()randme()randme()randme()randme()randme() randme()randme()randme()randme()randme()randme()randme()randme() randme()randme()randme()randme()randme()
See perlop for the meaning of the flags and some examples.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|