Hmm ... wel you may still have issues with the underlying c code but pack("i",15) will no give you a null character but a 4 byte value containing the SI (shift in character - who uses that?). To create a one character null, you would need
pack( c, 0 );
-derby