There is a problem with using `~` in Perl: it assumes that arithmetic operations should be done in floating point. I tried `~0x56` and I got `18446744073709551529`. Adding `use integer` should fix this.