foreach $_(@TMP) { if ($_ =~ /^([\w.]+)$/) { $_ = $1; push (@hosts, $1); } else { next; } } #### foreach (@tmp) { push @hosts, $1 if /^([\w.]+)$/; }