$socket = 'socketa'; $connections{$socket} = {}; $connections{$socket}{name} = 'Bob'; $sockets{Bob} = $socket; #to access it $connections{$sockets{Bob}}; #### my $socket; my $name = 'Bob'; for my $key (keys %connections) { if($connections{$key}{name} eq $name) { $socket = $_; last; } } print "$socket is the socket for $name\n"; #### $connections{socket}{username} = "Bob";