As ikegami commented, I also found the indenting style to hamper understanding. This is more than line wrap, which is actually fine. It is a matter of what you have lined up with what. Example:
$FREQUENCY_QUERY->execute( ); while ( ($FREQUENCY_ID) = @FREQUENCY_QUERY = $FREQUENCY_QUERY- +>fetchrow_array() ) { $FREQUENCY_ID = "$FREQUENCY_QUERY[0]"; $FREQUENCY = "$FREQUENCY_QUERY[1]"; $CHANNEL_QUERY->execute( ); ### better ### $FREQUENCY_QUERY->execute( ); while ( ($FREQUENCY_ID) = @FREQUENCY_QUERY = $FREQUENCY_QUERY->fetchro +w_array() ) { $FREQUENCY_ID = "$FREQUENCY_QUERY[0]"; $FREQUENCY = "$FREQUENCY_QUERY[1]"; $CHANNEL_QUERY->execute( ); .... }
The studies that I've read say that the number of characters of indentation between levels should be either 3 or 4, 2 is too few and 5 or more is too many. In practice, I have found this to be good advice.

You claim that use strict; and use warnings; are being used. In the case of strictures, one of the purposes is to limit the visibility of variables to just where you need it. If there is some huge block that pre-declares things like $FREQUENCY_ID and gives it scope that makes it visible in all other code, it defeats the whole purpose.

I would expect to see code like this:

$FREQUENCY_QUERY->execute( ); while ( my ($FREQUENCY_ID, $FREQUENCY) = $FREQUENCY_QUERY->fetchrow_ar +ray() ) { $CHANNEL_QUERY->execute( ); .... } ####### #note # $FREQUENCY_ID = "$FREQUENCY_QUERY[0]"; #not needed, delete # $FREQUENCY = "$FREQUENCY_QUERY[1]"; #not needed, delete #
I don't think that your foreach() loops do what you want. If you replace "foreach" with "while", what happens will be very different, so it is not clear at all to me what you are saying works and what doesn't. See if you can replicate the problem with a much more simple example.

In reply to Re: Nested While Loops, foreach and next by Marshall
in thread Nested While Loops, foreach and next by Chipwiz_Ben

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.