pack two heads

Matts on 2003-04-01T15:18:45

Every now and then perl reveals a nice sweet feature that I didn't know existed before.

I need to send multiple strings across http. If I were doing this via RFCs I'd probably separate the strings with MIME boundaries. But I need speed and the most compact representation possible, so I'm using network-strings - length followed by the string itself. This way I can support binary strings (the first string contains \0's).

I figured I was going to have to do pack("Na*", length($string), $string), but no! Perl's pack() function lets me do:

pack("N/a*", $string)
And it all Just Works. The template above gives me a network-string. Sweet.

In other news, I hacked my open firmware today to support non-mirrored external displays ("extended desktop"). This is very cool. I've had a 19" LCD monitor sitting on my desk barely used since I started coding on my ibook. So now I have it hooked up to the iBook, and I have the screen arranged above the main laptop screen. It's very very cool IMHO.

All this is probably old hat to most people. But I'm still getting a kick from dragging windows from one screen to another. :-)