my %IP = ( # create and initialize '198.144.186.184' => { 'domain' => 'host.colocrossing.com', 'count' => 1, } ); ... # add to structure my $captured_IP = ...; my $captured_domain = ...; $IP{$captured_IP}{domain} = $captured_domain; $IP{$captured_IP}{count}++; ... # print structure -- see perldsc