use Data::Dumper; for my $host ( @ARGV ) { if ( $result->{$host} ) { print "Got host $host:\n", Dumper( $result->{$host} ); } else { print "Did not get host $host:\n", Dumper( $err->{$host} ); } }