my $string = 'abacadaeaf'; my $result = $string =~ s/a/x/g; print $result; # prints 5