I dont think there is an 'elegant' way to test each
hash key in a nested hash. You could always come
up with some funky loop and run exists on for each level. (my opinion
would be that Russ's code is not 'elegant', however it is a solution, but
there are probably dozens of solutions.)
Given that, why do you even want to test each key value?
Perl should not really care if it exists or not. Are you trying
to prevent warnings that might be occuring, or do you not want
the hash keys to be autovivified? The answer to this might
help guide us in the right direction. But if you dont care
about autovivification or 'Use of uninitialized value in ...'
warnings I would say to not worry about the tests. They will only
slow things down.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.