I am now on Twitter! Meet me on Twitter here (my nick is pkrumins.)
Or on Google Buzz and Facebook.

I decided one day that I want to master Perl’s pack() and unpack() functions to be able to manipulate data in Perl efficiently.
Perl’s pack and unpack are two functions for transforming data according to a user-defined template, between the guarded way Perl stores values and some well-defined representation as might be required in the environment of a Perl program. Unfortunately, they’re also two of the most misunderstood and most often overlooked functions that Perl provides.
As I wrote before, my way of learning these complex functions were to make a cheat sheet first with all the template parameters and then just spend a day reading more about them and experimenting.
As I usually print cheat sheets two pages per side and the pack/unpack cheat sheet consumed just one page, I added Perl’s printf/sprintf format and attribute summary.
Here is how I printed this cheat sheet:
(Sorry for the bad quality, I shot it with my camera phone)
PDF:
Download link: perl's pack/unpack and printf cheat sheet (.pdf)
Downloaded: 53673 times
Microsoft Word 2000 format (.doc):
Download link: perl's pack/unpack and printf cheat sheet (.doc)
Downloaded: 1703 times
Did you like this post? Subscribe here:
If you really enjoyed the post, I'd appreciate a gift from my geeky Amazon book wishlist. Books would make me more educated and I could write even better posts. Thanks! :)


(4 votes, average: 3.5 out of 5)
|
|
|


September 3rd, 2007 at 2:28 pm
[…] pack/unpack […]
October 2nd, 2007 at 3:55 pm
Thanks!
October 9th, 2007 at 7:20 am
[…] pack/unpack. See also Peteris’ excellent articles on Downloading YouTube Videos and Perls’ Special Variables. […]
February 7th, 2008 at 12:18 am
My perl cheat sheet compilation has been updated with this one per your request :)
http://www.scottklarr.com/topic/106/perl-cheat-sheets/
August 19th, 2009 at 8:49 am
Handy cheat sheet, ta! Could benefit from a few examples at the end, but dead useful information nonetheless. Smart!