Could you describe what it is that you are trying to do?

It looks like you are simply reading everything from one file and then appending it to another? Going by the output filename this is just a test, but if that is your intention , then an OS command would achieve this much more easily.

With regard to the body of the if statement, you are only reading one line after the section header. Is this your intent?

And if the intent of this line

($final_gset[$i]), $tmps;

is to assign the line you read in, into an element of the array, then where is the assignment? Ie. '='.

Basically, theere is no need to assign to a temporary var and then to the array, you might as well do this directly

if (/POLYMORPH/) $final_gset[$i] = <IN>; }

If that is your intent, then the other problem with your code is that you are never incrementing $i, so you are always over the same element. Except, that you have never assigned a value to $i, so it has the value undef, which is illegal as an array subscript.

If you had

use strict; use warnings;

at the top of your program, Perl would have probably told you most of this.


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


In reply to Re: while loop not working by BrowserUk
in thread while loop not working by harry34

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.