As described in
perlop,
~ is the bitwise negation operator. A substitution returns the number of substitutions performed, though I can't imagine a good reason why you'd want bitwise negation of that return value.
Update: After reading JavaFan's comment below, I think you're looking at a victim of refactoring where no bugs were introduced.