in reply to Re: Does Perl support a given number of replacements ?
in thread Does Perl support a given number of replacements ?

There is a catch though. If 'B' contains 'a', (or the replacement of an 'a' to a 'B' creates a new 'a'), this doesn't quite do what you want. A simple case, assume 'a' is '\w' and 'B' is just 'B'. Then
$_ = 'pqrstuvw'; my $i = 3; while($i) { $i--; s/\w/B/; } print "$_\n"; __END__ Bqrstuvw