Sponsored Content
Top Forums Shell Programming and Scripting [Perl] Strange ne "NO" behavior. Post 302318755 by ejdv on Friday 22nd of May 2009 07:31:53 AM
Old 05-22-2009
[Perl] Strange ne "NO" behavior.

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:

Code:
##############################################################
# 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:

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:

Code:
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:

Code:
DISABLE_PURGE_NOTIF:           	NO

Now I get the following output:

Code:
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 ?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

"Odd" behavior exiting shell script

Is it normal behavior for a shell script that terminates to terminate its parent shell when executed with the "." option? For example, if I have the example script (we'll name it ex.sh): #!/bin/sh if then echo "Bye." exit 2 fi And I execute it like this: >./ex.sh It... (6 Replies)
Discussion started by: DreamWarrior
6 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. UNIX for Advanced & Expert Users

"╭─ " Character combo in $PATH causes strange autocompletion behavior in zsh

I've posted about this before, but only recently narrowed the problem down to a specific cause. Ok, first of all, the behavior: It occurs when autocompletion brings up its list (not when there is only a single option). Basically, if I were to type, say, cd ~/<TAB> I would get something... (2 Replies)
Discussion started by: marshaul
2 Replies

5. UNIX for Advanced & Expert Users

Weird "sort" behavior

Hi, I'm trying to sort a text file "test": S12 S_S12 S_S1_12 S15 S_N15 S_N1_15 By "sort test", I get: S12 S15 S_N1_15 S_N15 S_S1_12 S_S12 It seems weird: Comparing Line 2 and Line 3, it must be that '-' is bigger than '1'; however, comparing Line 3 and Line 4, it seems that... (3 Replies)
Discussion started by: intermilan
3 Replies

6. Shell Programming and Scripting

Commenting out "expr" creates weird behavior

This really puzzles me. The following code gives me the error 'expr: syntax error' when I try to do multi-line comment using here document <<EOF echo "Sum is: `expr $1 + $2`" EOF Even if I explicitly comment out the line containing the expr using "#", the error message would still exist... (3 Replies)
Discussion started by: royalibrahim
3 Replies

7. Programming

Strange "getsockopt" Solaris behavior

Please take a look on following code: s = socket(PF_INET, SOCK_STREAM, 0); //socket fcntl(s, F_SETFL, O_NONBLOCK); //set socket to nonblock retry_conn: ret = connect(s, (struct sockaddr *)&serv_addr, sizeof(struct sockaddr_in)); // try to connect, for sure... (7 Replies)
Discussion started by: revolta25
7 Replies

8. Shell Programming and Scripting

Weird behavior of command "local"

Hi there, I'm running into a very weird situation. Let's forget about the purpose of my initial script please. I noticed the bug whatever I'm trying to do. I'm on an old server running bash 3.1.17. Say we have the following script : foo:~# cat /tmp/test #!/bin/bash f1() { local... (9 Replies)
Discussion started by: chebarbudo
9 Replies

9. Shell Programming and Scripting

Why awk print is strange when I set FS = " " instead of FS = "\t"?

Look at the following data file(cou.data) which has four fields separated by tab. Four fields are country name, land area, population, continent where it belongs. As for country name or continent name which has two words, two words are separated by space. (Data are not accurately... (1 Reply)
Discussion started by: chihuyu
1 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
Picture(3U)						    InterViews Reference Manual 					       Picture(3U)

NAME
Picture - composite structured graphic SYNOPSIS
#include <Unidraw/Graphic/picture.h> DESCRIPTION
A Picture defines a composition of graphic objects. A picture has its own graphics state, which it concatenates with its children's state when it is drawn or erased. Picture adopts the default concatenation semantics supported by the Graphic base class: The picture's graphics state effectively overrides its children's so that they are drawn with the picture's state information substituted for their own. A child's attribute is used only when the picture does not already define it. Moreover, each child's transformer is postmultiplied by the picture's transformer when the picture is drawn; thus children are drawn relative to the picture's coordinate system. PUBLIC OPERATIONS
Picture(Graphic* = nil) Construct a new picture, optionally supply a graphic from which to copy an initial set of graphics state. Picture is derived from FullGraphic and therefore defines a full set of graphics state. virtual ~Picture() The picture deletes its children when it is deleted. boolean IsEmpty() Picture defines IsEmpty in addition to the standard Graphic child traversal operations to provide a convenient way to check if the picture has any children. PROTECTED OPERATIONS
Graphic* graphic(UList*) UList* Elem(Iterator) Convenience functions for extracting a graphic from a UList element and a UList from an iterator. SEE ALSO
Graphic(3U), Iterator(3U), Transformer(3I), UList(3U), pspaint(3U) Unidraw 1 February 1991 Picture(3U)
All times are GMT -4. The time now is 01:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy