Your code seems ok to me:
c:\@Work\Perl\monks>perl -wMstrict -le
"my @strings = (
'SMS,SMS1,20190811',
'SMS,SMSh,20190811',
'SMS,SMSH,20190811',
'SMS,SMSx,20190811',
'SMS,SMSi,20190811',
'SMS,SMSX,20190811',
'SMS,SMSI,20190811',
);
;;
for my $s (@strings) {
my $ref_s = \$s;
print qq{'$$ref_s' matches}
if $$ref_s =~ /SMSi/i
|| $$ref_s =~ /SMSI/i
|| $$ref_s =~ /SMSh/i
|| $$ref_s =~ /SMSH/i
|| $$ref_s =~ /SMS1/
;
}
"
'SMS,SMS1,20190811' matches
'SMS,SMSh,20190811' matches
'SMS,SMSH,20190811' matches
'SMS,SMSi,20190811' matches
'SMS,SMSI,20190811' matches
What am I doing differently from what you're doing?
Update 1: Here's a variation showing assignment via reference (and aliasing). Again, I think it works the way I think you think it should work. (Maybe take a look at Short, Self-Contained, Correct Example.)
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le
"my @strings = (
'SMS,SMS1,20190811',
'SMS,SMSh,20190811',
'SMS,SMSH,20190811',
'SMS,SMSx,20190811',
'SMS,SMSi,20190811',
'SMS,SMSX,20190811',
'SMS,SMSI,20190811',
);
;;
for my $s (@strings) {
my $ref_s = \$s;
$$ref_s = 'SMSblk'
if $$ref_s =~ /SMSi/i
|| $$ref_s =~ /SMSI/i
|| $$ref_s =~ /SMSh/i
|| $$ref_s =~ /SMSH/i
|| $$ref_s =~ /SMS1/
;
}
;;
dd \@strings;
"
[
"SMSblk",
"SMSblk",
"SMSblk",
"SMS,SMSx,20190811",
"SMSblk",
"SMS,SMSX,20190811",
"SMSblk",
]
Update 2: BTW: I'd tend to write something like this a bit differently:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le
"my @strings = (
'SMS,SMS1,20190811',
'SMS,SMSh,20190811',
'SMS,SMSH,20190811',
'SMS,SMSx,20190811',
'SMS,SMSi,20190811',
'SMS,SMSX,20190811',
'SMS,SMSI,20190811',
);
;;
for my $s (@strings) {
my $ref_s = \$s;
$$ref_s .= ' is SMSblk' if $$ref_s =~ /SMS[iIhH1]/;
}
;;
dd \@strings;
"
[
"SMS,SMS1,20190811 is SMSblk",
"SMS,SMSh,20190811 is SMSblk",
"SMS,SMSH,20190811 is SMSblk",
"SMS,SMSx,20190811",
"SMS,SMSi,20190811 is SMSblk",
"SMS,SMSX,20190811",
"SMS,SMSI,20190811 is SMSblk",
]
And maybe also throw in some kind of boundary assertion like
\b so the final regex might look like
/ \b SMS[iIhH1] \b /x
to prevent a string like
'SMS,xSMSHx,20190811' from matching.
Give a man a fish: <%-{-{-{-<