私は perl を初めて使用し、ネットワーク形式の ipv6 アドレスを ASCII 文字列形式に変換しようとしています。「ソケット」モジュールの「inet_ntoa」関数を使用して、ipv4 アドレスに対してこれを行うことができます。新しいモジュールをインストールせずにIPv6アドレスに対してこれを行う方法は?
3010 次
1 に答える
1
perldoc Socketinet_ntop
で推奨されているとおりに使用します。
$string = 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.
$string = inet_ntop $family, $address
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.
于 2015-09-02T10:26:23.093 に答える