- or download this
s/$c$a/$c$b/g;
or
s/($c)$a/$1$b/g;
- or download this
use Benchmark;
use vars qw/$a $b $c/;
...
lookbehind => sub { local $_ = "foobarquux"; s/(?<=$c)$a/$b/g
+},
chromatic => sub { local $_ = "foobarquux"; s/($c)$a/$1$b/g
+},
});
- or download this
Benchmark: timing 500000 iterations of chromatic, lookbehind...
chromatic: 15 wallclock secs (14.46 usr + 0.00 sys = 14.46 CPU)
lookbehind: 13 wallclock secs (11.93 usr + 0.00 sys = 11.93 CPU)