I have a script that does a bunch of calculations on IPV4 and IPV6 address’s in their hex form
for example “70.02.03.04” would be
$ipv4=”\x46\x02\x03\x04″
This binary handle is hardcoded in my script. But now I want to generate this on the fly
I’m using “sprintf(“x%02x”, $value) for hex values, but how would I generate the binary handle as above?
You don’t want hex (a string representation of a number).
You want the number as a four byte machine integer.
You can achieve this using
and with