Just be cause the number of elements is even, doesn't mean there is no problem.

If this is a nested hash, I'd also check for use of refs (or objects) as the hash key.

On a related note, can anyone suggest a way of determining the location of the offending problem(s)?
Well, the best I can think of is to use diff to compare the source before and after. If it worked before, the error lust be in what changed.

Also: you may want to apply stricter rules to the format of the source code, than perl allows. For example, you could demand that new keys for the hash are always on a new line.

Perhaps you can build a validator for rules like these, using PPI? Don't spend too much time on it, or it might be faster to convert this to a database. Which is what I'd really recommend. (Maintain the contents with a generic CRUD tool, maybe build one with a CRUD builder toolkit; and access the DB contents with DBIx::Simple/SQL::Abstract, which is my preferred way to exchange data between Perl and an SQL DB.)


In reply to Re: Determining presence of odd number of hash elements, other syntax problems by bart
in thread Determining presence of odd number of hash elements, other syntax problems by nicku

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.