Yes, I have the same issue when getting strings back using the Win32::API module. I allocate room, pass it as a parameter, and then the secret is to chop off the string at the first \0 character. Perl doesn't see it as special so it prints the whole length. The C code marked the actual end with a \0. So try something like
s/\0.*$//. Most cases I get the actual length back too and just truncate to that known length.
The x to make a long buffer works for me.
—John