in reply to Count replaces in search and replace
In scalar context, substitution returns the number of replacements, i.e.
$number = $_ =~ s/$replace/$map{$replace}/gi;