my $astring = "some string"; my $svptr = (\$astring)+0; #works on 32 bit ONLY my $packesvptr = pack('L', $svptr); my $svbinary = unpack('P[L4]', $packesvptr); my $packedPV = substr($svbinary, 4*3, 4); print "\"".unpack('p', $packedPV)."\"";#null terminated, use 'P[12345]' for binary data print "\n\nExample 2\n\n"; $packedPV = pack('p', $astring ); print "\"".unpack('p', $packedPV)."\"";