This is precisely where my mind was when I read the question, but to be accurate, you'd have to reverse the logic a bit. Because RFC 4291 allows for v4 mapped addresses (IPv4 addresses embedded within the v6 address), searching for a dot may give false positives in rare circumstances. The following corrects that problem unambiguously:
if ( $addr =~ /:/ ) { print "IPv6"; } else { print "IPv4"; }
In reply to Re^2: program to differentitate IPV4 and IPV6 address
by stevieb
in thread program to differentitate IPV4 and IPV6 address
by snimmaka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |