use Benchmark; use vars qw/$a $b $c/; ($a, $b, $c) = qw/bar baz foo/; timethese(shift || 500000, { lookbehind => sub { local $_ = "foobarquux"; s/(?<=$c)$a/$b/g }, chromatic => sub { local $_ = "foobarquux"; s/($c)$a/$1$b/g }, chromatic2 => sub { local $_ = "foobarquux"; s/$c$a/$c$b/g }, });