On 05/01/2013 07:04 PM, Peter Martini wrote: > On Wed, May 1, 2013 at 12:53 PM, Steffen Mueller > <mail@steffen-mueller.net> wrote: >> [side-track] >> >> On 05/01/2013 06:44 PM, demerphq wrote: >>> >>> My understanding of pack()s original intention was to allow one to >>> construct C structures in Perl. As such introduces a change which >>> basically means one cannot safely put a string into a C structure >>> without the possibility of the entire structure being corrupted by >>> doing so doesn't make sense. >> >> >> In all fairness, if you use pack to do that, you'll be writing VERY >> unportable code due to alignment, padding and friends. But don't listen to >> me: Have a look at the docs for Convert::Binary::C. Marcus knows a lot >> better than I do. > For what it's worth, I often use pack/unpack when I'm working with > network protocols. The endianness and encoding are well defined and > may differ from the architecture of the system I'm working on. The > main example I can think of was talking from a SPARC/Solaris or > Intel/linux host to a Windows service, which meant not only did it it > have to pay attention to endianness for the encoded length fields, it > had to convert encoded text data from UTF-16 to UTF-8 as well. That's entirely not the same as C structs. :) This being said, I'm surprised you haven't run into the "passing a scalar with UTF8bit set to pack("v/a")" issue. Are you running old perls? --SteffenThread Previous | Thread Next