in reply to Re: Switch/Format to not interpret metacharacters in regex?
in thread Switch/Format to not interpret metacharacters in regex?

I'm actually fixing someone elses code, based on the actual code the fix might be as simple as:
if (lc($b) eq lc($a)) { print "do something...\n"; }
However the first answer (using /\Q$a\E/) has immediately fixed the issue and knowing the data it will be a permanent fix for the issue... it also taught me something that I probably have come across in the past... 20+years working with perl and I still learn something new every so often... :)

Thanks, all.

Replies are listed 'Best First'.
Re^3: Switch/Format to not interpret metacharacters in regex?
by kcott (Archbishop) on Dec 04, 2019 at 06:30 UTC

    G'day mis,

    Welcome to the Monastery.

    Two quick points:

    • $a and $b are special variables which I'd recommend avoiding except for their special purposes. See perlvar: $a for more information.
    • Instead of using lc (or uc) consider fc. Note that you'll need Perl 5.16 for that.

    — Ken