I decided one day that I want to master Perl's pack() and unpack() functions to be able to manipulate data in Perl efficiently.
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:
Download Perl pack/unpack and printf Cheat Sheet
- PDF document: perl.pack.unpack.printf.cheat.sheet.pdf
- MS Word document: perl.pack.unpack.printf.cheat.sheet.doc
See you next time!