Hi, How do I best test for a valid host name? My script will read from a file which contains IP addresses and/or dns name, so I'm trying to sort out valid IP addresses or host name (using regex). For some reason, my regex fails to match host names with one or more dash (-). IN the example below, it fails to match "host-no.top-level" as a valid host name. I modify the regex several times - but still don't get the right outlook.
my @hosts = qw(192.168.22.1 192.168.22.18 localhost another.host.domain host-no.top-level my.host.domain.com); foreach (@hosts){ # Works ok push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/; # Can't match "host-no.top-level". push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/; } Thanks.. Babs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>