for my $val ( keys %host_add ) { for ( @{ $host_add{$val} } ) { print $val, q{ }, join " ", @{ $host_add{$val} }, $/ if $_ =~ m{CRIT|DMZ}; } }