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

    You need to create boundaries to get an exact match when using that syntax:

    if($SRVCHX =~ m/^$HOSTNME$/i)

    or else things like "one" =~ /on/i; will match.

      Got one, missed one. The provided example value was an FQDN and contains dots. ;)

        Nice catch. Thanks :)

        Thanks Thomas, your trick worked. :)

      Thanks Stevieb, your trick worked. Great Help:)

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

    Thanks dasgar