my $text = "my dog is green"; my $count; $count++ while $text =~ /(g)(.)/g; print $count;