On Feb 3, 2004, at 12:33 PM, Marcus Holland-Moritz wrote:

On 2004-02-03, at 08:14:19 -0800, Chris Masters wrote:

How do I use the pointer within perl? I need to loop
through each byte and print it's value (in hex or
binary).

No way. The pointer is useless inside a perl script.

Pointers are perfectly usable from Perl, with a little pack()/unpack() trickery. Assuming that the function foo() returns a void* in an IV:


my $pointer = pack('L', foo());
my $char_array = unpack('P12', $pointer);
my @chars = unpack('c12', $char_array);

It's certainly not the most intuitive or readable code in the world, but it does work.

sherm--



Reply via email to