in reply to randomizing global replacement
You left the /e off the regex:
use strict; use warnings; my @a = ('b' .. 'j'); my $str = 'a' x 23; $str =~ s/a/$a[rand@a]/ge; print "$str\n";
Prints:
dbjgcegjgieigecihebhdih
Oh, and don't use $a as a general purpose variable - it's magical ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: randomizing global replacement
by lokiloki (Beadle) on Jan 30, 2007 at 04:15 UTC | |
by ysth (Canon) on Jan 30, 2007 at 04:24 UTC | |
by GrandFather (Saint) on Jan 30, 2007 at 04:32 UTC |