my $text = "my dog is green"; my $count = ( $text =~ /g/g ); # $count is 2