I'm not sure what you mean by "[w]hen I do one "if" statement, it skips over the second, and so on. Second "if" only works when I restate the "while" and so on". Could you clarify?

I'm guessing that your problem's to do with the fact you're exhausting your filehandle. while(<WGL>) will read the entire file, line by line; if you then attempt to read from it again, e.g. in a second while loop further down in a similar block of code, it'll try to continue where you last left off, notice it's already at the end of the file, and not execute the loop body even once.

That's easily remedied by using seek, though: seek WGL, 0, SEEK_SET will move the filehandle's position to the beginning of the file again.

Is that the problem you're having?


In reply to Re: Nested if and while statements by AppleFritter
in thread Nested if and while statements by crisa89

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.