in reply to Accessing Multilevel Hash Values
Assuming you mean that "socket" is actually a variable and not the hash key itself, this would give you a list of all matching sockets:
my @sockets = grep { ref $connections{$_} eq 'HASH' && $connections{$_}{username} eq 'Bob' } keys %connections;
-jehuni
Update: Just to clarify, the ref $connections{$_} eq 'HASH' part is just in case you have things in %connections which are not hashrefs. On the other hand, if they're guaranteed to always be hashrefs, you could drop that check and just do:
my @sockets = grep { $connections{$_}{username} eq 'Bob' } keys %conne +ctions;
|
|---|