@strings = ( 'There was a bright man from Nantucket' ,'Abba babbles about bubble blowers' ,'Enough with the excess bs already' ,'None at all in this one'); my @c; use Benchmark 'cmpthese'; %methods = ( 'anch' => sub { s/b(?=[^b]*$)/x/ for @c=@strings}, 'xeger' => sub { $_ = reverse, s/b/x/, $_ = reverse for @c=@strings }, 'plain' => sub { s/(.*)b/$1x/ for @c=@strings}, '2part' => sub { /.*(?=b)/g and s/\Gb/x/ for @c=@strings }, '2part-A' => sub { /b(?=[^b]*$)/g and s/\Gb/x/ for @c=@strings }, 'substr' => sub { substr($_, rindex($_, 'b'), 1) = 'x' for @c=@strings}, 'neglook' => sub { s/b(?!.*b)/x/ for @c=@strings } ); cmpthese(-3, \%methods );