The part that's hard to see is that there must be exactly one double colon :: in the address ... unless there are exactly seven colons, in which case there must be no double colon. For example,
0001:0002:0003:0004:0005:0006:0007:0008
The other and more important thing - which I forgot altogether - is that addresses that are mapped from IPv4 to IPv6 can optionally be written with the last two groups of hex digits replaced by a dotted-decimal IPv4 address, as in these two:
::ffff:10.32.12.1
::10.32.12.1
which are equivalent to
::ffff:0a20:0c01
::0a20:0c01
I think the suggestion from an Anonymous Monk of "Work less, use Net::IPv6Addr" is really a much better idea.
Adding the code to parse mapped address would turn the code I suggested from a mess into an abomination... a useful one to be sure, but still very very abominable. As Otto von Bismark might say, "Some CPAN modules are like laws and sausages, it is better not to see them being made."
|