# loop starts upward of here # $key must be scoped outside the loop chomp; if (/^\d+\.\d+\.\d+\.\d+$/) { next unless $key; push @{$CoreRegR{$key}}, $_; # Alt. replace the prev 2 lines with # push @{$CoreRegR{ $key || 'unnamed host' }}, $_; } else { $key = $_ } # ...