for my $acct_id (keys %customers) { print "Account: $acct_id\n"; for my $ip (keys %{$customers{$acct_id}}) { # Do stuff here with IP print "IP: $ip\n"; for my $id (keys %{$customers{$acct_id}{$ip}}) { print "ID: $id\n"; } } }