in reply to Pattern Matching: Case-Conservation
I think maybe a logical problem in your question needs clarification.
If you replace X with Y thats fine
If you replace X OR Y with Z that is also fine logic
But you cannot wish to replace X OR Y with V OR W.
You can have 2 rules mapping X to V and Y to W, but not within
the same substitution.
The lvalue of a substitution may be a choice
The rvalue cannot be
I think you want to use 'map'.
However heres a suggestion.
Sounds like the problem is that you want semanitic (meaning) of the word match, which is a separate issue from the capitalisation of letters. Store lowercase only versions of the strings, and a binary sequence coresponding to capitalisation as a hash pair
eg.
DooD -> dood , 1001
RanDoMcAPS -> randomcaps, 1001010111
Use your lc strings to do the matching (which might be mildly happier for a smaller search space)
and the capitalisation 'bumpmap' to regenerate the
original.
There is also a very elegant way to derive and reapply the 'bumpmap' digits, which I'm sure is an easy exercise in Perl.