in reply to unpack "P" and a horrible death

I don't know, this works fine for me:
$s = pack "L", 0x03141593; # 4 byte string $p = pack "P", $s; # pointer printf "%08X\n", unpack "L", unpack "P4", $p;
Result:
03141593
It would appear to me that your code looks fine.

update No it doesn't. pack "P", $string returns a packed pointer, i.e. a 4 byte structure, containing a packed integer with the numeric pointer value. unpack "P", $packed_pointer does the reverse: first unpacking the address from the 4 bytes, and then unpacking the string it points at. So it does a double unpack.

$s = "Kettle Of Fish"; # 14 byte string $p = pack "P", $s; # packed pointer printf "Length of the pointer: %d\n", length $p; printf "10 byte string: %s\n", unpack "P10", $p;
Result:
Length of the pointer: 4
10 byte string: Kettle Of 

In summary: you'd have to convert your numerical pointer to a packed integer, and then unpack using "P4". You can then unpack the integer in that string.

$int= unpack "L", unpack "P4", pack "L", $addr;