in reply to Re: Stop variable expansion
in thread Stop variable expansion

Excellent. Index did the trick. I think indexing is the better solution than character replacement since I don't have to think about all possible characters that could cause issue, and it just does the comparison character by character regardless, which is really what I want in this case. Expanding the regular expression is also extremely useful and I use it a lot in other applications but thought I had to explicitly enable it (with eval) rather than explicitly disable it somehow. Anyhow. Thanks for the solution :) BR, Steve

Replies are listed 'Best First'.
Re^3: Stop variable expansion
by AnomalousMonk (Archbishop) on Mar 19, 2021 at 06:05 UTC
    I think indexing is the better solution than character replacement ...

    index seems a very good match to your use-case.

    ... I don't have to think about all possible characters that could cause issue ...

    That's exactly what quotemeta (and its \Q...\E avatar) does for you: escape all characters that could possibly cause an issue.

    Expanding the regular expression is also extremely useful and I use it a lot in other applications but thought I had to explicitly enable it (with eval) rather than explicitly disable it somehow.

    I don't understand what this means. Are we still talking about meta-quotation? Could you give an example of what you're doing with eval? (Please see Short, Self-Contained, Correct Example.)


    Give a man a fish:  <%-{-{-{-<