in reply to Re: I just want IF, OR, OR not every one
in thread I just want IF, OR, OR not every one

I think you are close, but still you don't get a cookie!
I'm trying to test to see if bgs is in the file.

if it is not. I add the here document $bgs above syslogd.

But, if it is there. It adds the $here document anyway.

Perhaps the OP wanted to test if $line does NOT contain the literal string 'bgs' and was what he really meant to write $line !~ /bgs/ rather than $line =~ /!bgs/

Then of course his first test falls through (although he thinks erroneously that it succeeds) and to his utter confusion the other conditions in the elsif chain get tested until one succeeds. Hence his question about how the if -- elsif -- else construct works and how to avoid multiple results in this chain to apply, which got us all confused as only one condition can succesfully apply.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^3: I just want IF, OR, OR not every one
by wcj75019 (Acolyte) on Feb 29, 2008 at 20:18 UTC
    Count, That that was a good thought. I like where your head is. But, that continuously prints $bgs here documents. Thanks,
      Well that should not surprise you.

      Your program reads a line from your file and puts this line in $line. You then check if this line contains the literal string bgs and if not you print the content of your HERE-doc variable $bgs. Due to the next instruction, program execution then jumps straight to the continue block and prints the contents of $line

      NOW WATCH THIS!

      You then read the next line of the file and check again if this new line contains the literal string bgs ...

      So for every line not containing the literal string bgs the contents of $bgs get printed. This is not what you want:

      I'm trying to test to see if bgs is in the file.
      You will have to rethink the logic of your program to make sure that you test for the presence of bgs in the whole of the file and for each line.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James