in reply to Re^2: Inverse regexes for input validation
in thread Inverse regexes for input validation

Not that it makes a whole lot of difference in your case, but the "tr///" operator is especially good for this sort of thing -- it's demonstrably faster than "s///" (utf8 wide characters don't even seem to slow it down), and the syntax is a little easier:
my ( $text ) = shift; $text =~ tr/ 0-9A-Za-z-//cd; return $text;
The "c" modifier says the match should apply to the complement of the characters cited, and with no characters in the replacement side, "d" says delete all matched characters.