in reply to HoH search question

Personally, I would say that you are using the wrong data structures. The keys of you primary hash are 'pc' + n. The pc part is repetative and reduntant. Your left with n, which gives you an array.

In you secondary hashes, your keys are all identical and only the values vary. The greatest benefit of a hash is the ability to look things up by name, but your not able to use this effectively. All your keys are again, repetative and redundant.

I think I would use something like this.

#! perl -slw use strict; my( %users, @linux, @win32 ); my @pcs = ( [ 'win32', 'dave' ], [ 'linux', 'john' ], [ 'win32', 'robin' ], ); for( 0 .. $#pcs ) { my $pc = $pcs[ $_ ]; $users{ $pc->[1] } = $_; push @{ $pc->[0] eq 'linux' ? \@linux : \@win32 }, $_; } print 'Linux users: ', join ' ' , map{ $_->[1] } @pcs[ @linux ]; print "Dave's pc is number $users{ dave } attributes:" , join ' ', @{ $pcs[ $users{ dave } ] }; print "Win32 pc numbers: @win32\n\t" , join "\n\t", map{ join ':', @$_ } @pcs[ @win32 ]; __END__ Linux users: john Dave's pc is number 0 attributes:win32 dave Win32 pc numbers: 0 2 win32:dave win32:robin

This scheme allows you to answer all of the questions you mentioned using direct or 1 level indirected indexing with no searching.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.