I have a few comments for you. I will leave the dereferencing code out of my response because my main points have to do with the regex matching part and also I don't really understand what you are doing with your deref of a reference to a scalar.

First I would not match against the whole comma separated line, I would narrow the focus to the field that you are interested in. Below I use a split to get field[1]. Another poster suggested using a boundary condition in the regex for the same intended purpose (making sure you are matching against what you think that you are). We don't know what those other names or id's in the line look like, perhaps one server is "sms1Master" or whatever.

Instead of multiple "or" terms, I would use a character set in this case. This makes it easier for me to see what is going to match or not match. Of course mileage varies.

use strict; use warnings; while (<DATA>) { my $SMSfield = (split(',',$_))[1]; if ($SMSfield =~ /SMS[1HI]/i) { print "Match $SMSfield\n"; } else { print "No Match $SMSfield\n"; } } =prints Match SMS1 Match SMSh Match SMSH Match SMSi Match SMSI Match SmsI **Note this match** I think in your case, this is fine. No Match SMSx =cut __DATA__ SMS,SMS1,20190811,084500,servname,servid,servname1,s1,400,300,300,300, +300,300 SMS,SMSh,20190811,084500,servname,servid,servname1,s1,700,300,300,300, +300,300 SMS,SMSH,20190811,084500,servname,servid,servname1,s1,600,300,300,300, +300,300 SMS,SMSi,20190811,084500,servname,servid,servname1,s1,800,300,300,300, +300,300 SMS,SMSI,20190811,084500,servname,servid,servname1,s1,500,300,300,300, +300,300 SMS,SmsI,20190811,084500,servname,servid,servname1,s1,500,300,300,300, +300,300 SMS,SMSx,20190811,084500,servname,servid,servname1,s1,500,300,300,300, +300,300

In reply to Re: Case insensitive string comparison by Marshall
in thread Case insensitive string comparison by DAN0207

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.