$_ = 'a a a a a a a a'; my $i = 3; while($i){ $i--; s/a/B/; } print "$_\n"; __END__ B B B a a a a a