in reply to Perl IF Issue
In addition to the suggestions about checking the values of the two variables, I've got two ideas. First thought: do you have the variable names correct? Using a variable named $HOSTNME instead of $HOSTNAME seems a bit odd to me personally and I'm just wondering if you might have a slight typo there. As choroba pointed out, using strict will help catch this kind of typo with variable names.
The other idea is that maybe the two variables have basically the same string, but without exact case matching (such as 'MyServer' and 'myserver'). The eq operator is looking for exact matches, which means that it is doing case-sensitive matching.
If you want/need case-insensitive matching, you just need to use a simple regex instead. Basically, change:
if($SRVCHX eq $HOSTNME )to be:
if($SRVCHX =~ m/$HOSTNME/i )
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl IF Issue
by stevieb (Canon) on Aug 20, 2015 at 16:13 UTC | |
by Monk::Thomas (Friar) on Aug 20, 2015 at 16:17 UTC | |
by stevieb (Canon) on Aug 20, 2015 at 16:26 UTC | |
by intoperl (Acolyte) on Aug 20, 2015 at 16:37 UTC | |
by intoperl (Acolyte) on Aug 20, 2015 at 16:38 UTC | |
Re^2: Perl IF Issue
by Monk::Thomas (Friar) on Aug 20, 2015 at 16:15 UTC | |
Re^2: Perl IF Issue
by intoperl (Acolyte) on Aug 20, 2015 at 16:36 UTC |