in reply to Re: Case insensitive string comparison
in thread Case insensitive string comparison
I agree with matching against a particular field rather than against the entire string, and with using a character class rather than several regexes | matches in tandem.
I have some comments regarding implementation details. I'm forced to admit, however, that because I don't really know DAN0207's requirements, these comments may be meaningless. That said, I forge ahead.
Firstly, the /SMS[1HI]/i match against the extracted $SMSfield field allows a field like 'xSMSIx' to be accepted. This match could benefit from anchor assertions: / \A SMS [1HI] \z /xi rejects this field.
Secondly, I find the use of the global /i flag problematic. In the OPed code statement
$$blk_ref = 'SMSblk' if $$blk_ref =~ /SMSi/i || ... || $$blk_ref =~ /SMS1/;
the /i modifier is only present in matches with an i I h H suffix, not with the numeric suffix. This suggests (and again, I'm only guessing) that the 'SMS' subfield of the field in question should not be matched case-insensitively. If that's so, a match of
/ \A SMS [1hHiI] \z /x
(which I personally prefer) or
/ \A SMS (?i) [1HI] \z /x
will reject the 'SmsI' field and all like it.
Give a man a fish: <%-{-{-{-<