in reply to Re^3: I just want IF, OR, OR not every one
in thread I just want IF, OR, OR not every one
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
|
|---|