TedPride has asked for the wisdom of the Perl Monks concerning the following question:
This is fine if I always sort the data this way, but what if I decide I want to use a 3-level hash without hard-coding the data assignment? How do I efficiently take an array of keys:$counts{$n{'Rep'}}{$n{'Item'}} += $n{'Qty'};
And translate it into:@keys = ('Rep','Item','Whatever');
It doesn't have to be neat, or the fastest code on the planet, but efficiency is somewhat of a concern. I suppose I could use eval (since this is an admin script and placed safely out of reach of hackers), but I'm interested in seeing if there are other ways.$counts{$n{'Rep'}}{$n{'Item'}}{$n{'Whatever'}} += $n{'Qty'};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assigning data to a nested hash with a variable number of levels?
by tlm (Prior) on Apr 19, 2005 at 03:49 UTC | |
|
Re: Assigning data to a nested hash with a variable number of levels?
by TedPride (Priest) on Apr 19, 2005 at 04:36 UTC |