my $num_substitutions = $var =~ s/foo/bar/g;