Hi there,
I have a strange problem and I cannot figure it out what I am doing wrong here.
Let me try to picture it.
In principle it is prety straight forward, but something odd is happening.
Here is part of the input file snmp_alm.cfg:
##############################################################
# Specifies if the PURGE Notification should be sent or Not #
# Yes means the PURGE Notification is Not sent (disabled) #
# No viceversa #
# Default Value is: NO #
##############################################################
DISABLE_PURGE_NOTIF: YES
Here is part of the Perl code:
my $disable_purge_notif;
my $disable_purge_notif_value;
open (SNMP_ALM_CFG, $snmp_alm_cfg) or die "Cannot open $snmp_alm_cfg";
while (<SNMP_ALM_CFG>) {
s/#.*//; # ignore comments by erasing them
next if /^(\s)*$/; # skip blank lines
s/^[\s\t]+//; # remove leading tabs and spaces
s/[\s\t]+$//; # remove trailing tabs and spaces
s/://; # remove :
chomp;
@_=split(/[\s\t]+/, $_, 2); # split on tabs on spaces
if (/DISABLE_PURGE_NOTIF/) {
$disable_purge_notif = $_[0];
$disable_purge_notif_value = $_[1];
printf "Found parameter : $disable_purge_notif\n";
printf "Current setting is : $disable_purge_notif_value\n";
if ( $disable_ack_notif_value ne "NO" ) {
printf "ERROR - Correct $disable_purge_notif setting is : NO\n";
}
}
}
close (SNMP_ALM_CFG);
This is the output when the parameter value is YES:
Found parameter : DISABLE_PURGE_NOTIF
Current setting is : YES
ERROR - Correct DISABLE_PURGE_NOTIF setting is : NO
So far so good.
But now I set it to NO:
DISABLE_PURGE_NOTIF: NO
Now I get the following output:
Found parameter : DISABLE_PURGE_NOTIF
Current setting is : NO
ERROR - Correct DISABLE_PURGE_NOTIF setting is : NO
I thought "NO" ne "NO" would give 0 or false.
Using the debugger I see that $disable_ack_notif_value is indeed 'NO', so I am confused here.
Anything I overlooked ?