Help for this page

Select Code to Download


  1. or download this
    s/$c$a/$c$b/g;
    
    or
    
    s/($c)$a/$1$b/g;
    
  2. 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  
    +},
        });
    
  3. 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)