http://qs1969.pair.com?node_id=11111226

The_Dj has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks.

For reasons probably best described as DBI, I have data like this:

%dat_by_id = ( 1=>{ id=>1, sn=>'a', more=>'foo' }, 2=>{ id=>2, sn=>'b', more=>'bar' } );

You get the idea.

Now, for reasons best described as argh! I also do:

%dat_by_sn=(map { $_->{sn} => $_ } values %dat_by_id);

Sadly I do need to reference entries be either field throughout the rest of the code.

Is there a better way? (My dataset runs to a few million records. Big but not too big.)

I don't (currently) need a 3rd,4th,...nth field, but it's only a matter of tiem untill someone adds a UID field, or something else to compicate my life