use warnings; use strict; my $str = "The quick brown fox jumps over the lazy dog"; my $count = ($str =~ s/(the)/$1/gi); print "$count\n";