my $count = 3; my $str = "blublublublublu"; $str =~ s/(lu)/--$count == 0 ? "LA":$1/ge;