title: How to convert a Perl hash-of-hashes to a more flexible data structure?
body: <p>In a quick-and-dirty Perl script, I have a data structure like this:</p>
  
  <pre><code>$tax_revenue{YEAR}{STATE}{GOVLEV}{TAX} = integer
  </code></pre>
  
  <p>The hash keys assume values like this:</p>
  
  <pre><code>YEAR: 1900 .. 2000
  STATE: AK, AL, ... WY
  GOVLEV: state, local
  TAX: type of tax (income, sales, etc.)
  </code></pre>
  
  <p>In addition, the hash keys are unique. For example, no value for the <code>TAX</code> parameter collides with a value for another other parameter.</p>
  
  <p>I am starting a medium-sized project working with this data and I would like to implement the data structure in a more flexible way. I don't know all of the data-retrieval functionality I will need yet, but here are some examples:</p>
  
  <pre><code># Specify the parameters in any order.
  Tax_rev( qw(1902 WY state property) );
  Tax_rev( qw(state property 1902 WY) );
  
  # Use named parameters.
  Tax_rev(year =&gt; 1902, state =&gt; 'WY', govlev =&gt; 'state', tax =&gt; 'property');
  
  # Use wildcards to obtain a list of values.
  # For example, state property tax revenue in 1902 for all states.
  Tax_rev( qw(1902 * state property) );
  </code></pre>
  
  <p>My initial inclination was to keep storing the data as a hash-of-hashes and to build one or more utility functions (probably as part of a class) to retrieve the values. But then I wondered whether there is a better strategy -- some way of storing the underlying data other than a hash-of-hashes. Any advice about how to approach this problem would be appreciated.</p>