#Only grab things associated with the current searched for ip and ends with .com .net and so on if (($array[7] =~ /[com|org|net|gov|cc|mil]\/$/)&&($array[3] eq $ip)) {