I have a problem where many people edit a complex Perl hash that is more than two megabytes in size. [I know, it's crazy.] Some human editors know Perl more than others. How to quickly identify that some component has an odd number of hash elements?

I can do that on the main file with:

my $error = qx(perl -we "require qq{$file}" 2>&1);
warn "$error\n" and return if $error;

But this main file also requires many sub files, which use global variables defined in the main file. This trick does not work with these sub files since there are many undefined global variables in these otherwise (normally) syntactically correct files.

Naturally, I am also doing something along the lines of  my $ok = 0 == system '/usr/bin/perl', '-Mstrict', '-c', $file; but that does not catch hashref components with odd numbers of elements.

Can anyone suggest a way of checking for odd number of elements in hashrefs and other such syntactical no nos?

On a related note, can anyone suggest a way of determining the location of the offending problem(s)?


In reply to 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.