use strict; use warnings; my $str = 'aa'; while ($str =~ /a/g) { $str =~ s/a/ba/g; print $str, "\n"; last if length($str)> 10; }