In Java I would do
System.out.println(new BigInteger(new byte[]{0,(byte)171,52,33}).intValue());
How would you do it in Perl?
In Java I would do
System.out.println(new BigInteger(new byte[]{0,(byte)171,52,33}).intValue());
How would you do it in Perl?
C:\Users\pgp\Documents\src\tmp>cat pack.pl
use Modern::Perl; # strict, warnings, v5.10 features
say unpack "N", pack "C4", 0, 171, 52, 33; # big endian
say unpack "V", pack "C4", 0, 171, 52, 33; # little endian
C:\Users\pgp\Documents\src\tmp>perl pack.pl
11220001
557099776
I can't remember what endianness Java specifies, but you can take your pick.
EDIT: as ysth helpfully points out, this has a 32-bit limit. I think there are pack options up to 64 bits, but no further. If you need arbitrary precision, his answer is better.