perl pack unpack printf sprintf cheat sheet

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:

perl pack unpack printf sprintf cheat sheet thumbnail
(Sorry for the bad quality, I shot it with my camera phone)

Download Perl's pack/unpack and printf Cheat Sheet

Download link: perl's pack/unpack and printf cheat sheet (.pdf)
Downloaded: 129146 times

Microsoft Word 2000 format (.doc):
Download link: perl's pack/unpack and printf cheat sheet (.doc)
Downloaded: 3618 times


October 02, 2007, 15:55


February 07, 2008, 00:18

My perl cheat sheet compilation has been updated with this one per your request :)

August 19, 2009, 08:49

Handy cheat sheet, ta! Could benefit from a few examples at the end, but dead useful information nonetheless. Smart!

Will hamlin Permalink
December 10, 2013, 03:43

Perl is on toff the most advance programming language we have.
Cheap refrigerator in french door style .

January 25, 2015, 20:38

Nice work man Keep, Its very Helpful for me how to check internet balance in aircel.........

January 27, 2015, 09:21

Nice Post Keep more posting


Kunal Shah</a

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "security_20": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.