I've been using the following functions as the basis for a lot of my IP calculation code for years. They require just the built in perl module Socket, so they were very portable.
sub ip2int { return( unpack("N",inet_aton(shift)) ) };
sub int2ip { return( inet_ntoa(pack("N",shift)) ) };
$ perl -MSocket6 -e '$x = inet_pton(AF_INET6,"2000::1"); print unpack("q",$x) . "\n"'
32
$ perl -MSocket6 -e '$x = inet_pton(AF_INET6,"2000::1"); print
unpack("Q",$x) . "\n"'
32
$ perl -MSocket6 -e '$x = inet_pton(AF_INET6,"2000::1"); print unpack("N",$x) . "\n"'
536870912
IPv6 addresses are 128 bits in size.
$ perl -e'
use feature qw( say );
use Socket6 qw( inet_pton AF_INET6 );
say 8*length(inet_pton(AF_INET6,"2000::1"));
'
128
You're very unlikely to have a Perl that supports 128-bit integers. You can enlist the help of Math::Int128
$ perl -e'
use feature qw( say );
use Socket6 qw( inet_pton AF_INET6 );
use Math::Int128 qw( net_to_int128 );
say net_to_int128(inet_pton(AF_INET6,"2000::1"));
'
42535295865117307932921825928971026433
There doesn't seem to be a Math::UInt128 (even though requesting to install Math::UInt128 installs Math::Int128), so this will actually give a signed number. You'll have to use something "fancier" like Math::BigInt to get an unsigned number.