As the only way (that I can think of), of "iterating over a %hash" is for my $key (keys %hash) { ... }, or one the essentially similar variations, the rule about not modifying your iterator whilst in a loop doesn't really apply in as much as, the iterator is iterating a list generated by the keys %hash code. So, if you choose to delete an element of the hash using delete $hash{$key}; whilst in the loop, you haven't modified the list in anyway, so I don't see any reason why you should not do this in one pass rather than two.

Without seeing the underlying logic and code, it's not possible to be certain that its safe to run your grammer and contents validations in the same pass, but I can't see any reasons why you shouldn't.

The only thing you really need to ensure is that you don't delete a complete lower level hash until all passes have been there and looked. This would be considerably easier in one pass than in 4 I think.

You might need to add some defensive if exists .... and/or if defined .... checks in there somewhere if you don't already have them.

I think I would definately try for the 1 pass method.


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

In reply to Re: Request opinions and ideas by BrowserUk
in thread Request opinions and ideas by gnu@perl

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.