1
我是新來的perl,我試圖將網絡格式的ipv6地址轉換爲ascii字符串格式。我可以使用「Socket」模塊中的「inet_ntoa」函數爲ipv4地址做到這一點。如何在不安裝任何新模塊的情況下爲ipv6地址執行此操作?inet_ntoa perl的ipv6
我是新來的perl,我試圖將網絡格式的ipv6地址轉換爲ascii字符串格式。我可以使用「Socket」模塊中的「inet_ntoa」函數爲ipv4地址做到這一點。如何在不安裝任何新模塊的情況下爲ipv6地址執行此操作?inet_ntoa perl的ipv6
使用inet_ntop
所推薦的perldoc Socket:
$字符串= INET_NTOA $ IP_ADDRESS
Takes a packed binary address structure such as returned by unpack_sockaddr_in() (or a v-string representing the four octets of the IPv4 address in network order) and translates it into a string of the form "d.d.d.d" where the "d"s are numbers less than 256 (the normal human-readable four dotted number notation for Internet addresses). This IPv4-only function is provided largely for legacy reasons. Newly-written code should use getnameinfo() or inet_ntop() instead for IPv6 support.
$字符串= inet_ntop $家庭,$地址
Takes an address family and a packed binary address structure and translates it into a human-readable textual representation of the address; typically in "d.d.d.d" form for "AF_INET" or "hhhh:hhhh::hhhh" form for "AF_INET6". See also getnameinfo() for a more powerful and flexible function to turn socket addresses into human-readable textual representations.