{foreach $port (@{$ref{$key}{'port'}}) #### for my $port (keys %ref){ my $host = $ref{$port}; # Process the $host/$port combo ...