use Math::BigInt; my $operand = '0x123456789abcdef0123456789abcdef0'; my $mask = '0x100000000f00000000000000000000f0'; print Math::BigInt->new($mask)->band($operand)->as_hex(), "\n"; #### my $anded = Math::BigInt->new($mask) & $operand; print $anded->as_hex(), "\n";