in reply to Re: Re: while loop not working
in thread while loop not working

The problem is that you seem to be aware that

while( <IN> ) {...

reads a single line, hence you need to loop back to read the next one, but then when you get to

if(/POLY/) { $final_gset[$i] = <IN>; ...

you seem to be expecting that line to somehow magically read multiple lines. It won't.

I might go into a more detailed explanation, but I still think that you don't need to write this program. You are (trying to ) read all the lines from one file and then append them to another. This would be much more easily accomplished using

C:\> type graph_set.txt >>test.txt

or$ cat graph_set.txt >>test.txt

depending which view of the world you see as being rightous:)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Replies are listed 'Best First'.
Re: Re: Re: Re: while loop not working
by Skeeve (Parson) on Jul 16, 2003 at 06:42 UTC
    Almost, but not exactly, Browser

    He wants all lines after POLYMORPH.

    So grep -v POLYMORPH graph_set.txt >>test.txt might be an option.

      Possibly true. I was hoping to pursuade Harry to elusidate a little upon his requirements so that we might offer a solution that fits his problem. I suspect that test.txt is simply that. A mechanism to test whether this part of the code is working rather than the final requirement.

      Which ever interpretation you place on the code as is, there are better ways of achieving the goal. If he would tell us what he wants, it would be easier to suggest something.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller