I assume your Find_First function modifies $repeat_flag according to some criteria. That's really the problem: it's unclear from this snippet that the subroutine call is controlling the loop. So here's one way to make it clearer.
OUTER: while (1) { while (($k, $v) = each %GRAMMAR) { last OUTER if Find_First($k, $v); } }
I may have the "sense" of the test backwards; depending on what else you're doing, unless might make more sense. Also, OUTER is not really a descriptive label outside of this example. Pick something that makes the last read better.

In general, I've found that using a variable to control a loop is a habit from other programming languages. Given Perl's powerful loop constructs, if you find yourself using a loop control variable, you may want to see if there's a way to avoid it. That's not an absolute; sometimes it's clearer to just say "while ($keepgoing)" or something, but often a last or next to a well-chosen label can be better. There's an excellent example in the perlsyn document regarding nested loops just like this.

HTH


In reply to Re: Help - I'm a C programmer by VSarkiss
in thread Help - I'm a C programmer by june_bo

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.