Unless you want to modify default variable $_ & save the number of replacements, there is typo in your s/// application. In that case, op should be (to save the result of all of replacements in another string) ...
( my $fixed = $input ) =~ s/ search / replace /x;
For fun, try the proposed s/(\s)/\\$whitespace{$1}/g solution on string x y (a plain space in between).
In reply to Re^3: Efficiently create an IF/ELSE regex
by Anonymous Monk
in thread Efficiently create an IF/ELSE regex
by jcrush
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |