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.

In reply to Re: Pattern Matching: Case-Conservation by andyf
in thread Pattern Matching: Case-Conservation by crazysniffable

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.