Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Is there a "pack() and unpack() for dummies"?

by Cap'n Steve (Friar)
on Nov 30, 2004 at 08:20 UTC ( [id://411128]=perlquestion: print w/replies, xml ) Need Help??

Cap'n Steve has asked for the wisdom of the Perl Monks concerning the following question:

More specifically, I need a simple explanation of all the different formats (or templates if you prefer) and what they're used for. I recently used perl to read and write a RAW image, but I would have never known what to use if someone hadn't told me.

A push in the right direction would be very helpful.

Replies are listed 'Best First'.
Re: Is there a "pack() and unpack() for dummies"?
by pelagic (Priest) on Nov 30, 2004 at 08:33 UTC
      I would second your opinion that this tut is a great resource. On a lighter note the OP is not alone. This node is a classic: Confession of a Perl Hacker and also has some useful pack/unpack hints.

      cheers

      tachyon

Re: Is there a "pack() and unpack() for dummies"?
by gaal (Parson) on Nov 30, 2004 at 08:32 UTC
Re: Is there a "pack() and unpack() for dummies"?
by wfsp (Abbot) on Nov 30, 2004 at 08:40 UTC
    perlpacktut

    "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. This tutorial will demystify them for you."
Re: Is there a "pack() and unpack() for dummies"?
by Zaxo (Archbishop) on Nov 30, 2004 at 08:37 UTC

    perldoc -f pack gives a quick reference for all the format strings.

    After Compline,
    Zaxo

Re: Is there a "pack() and unpack() for dummies"?
by Fletch (Bishop) on Nov 30, 2004 at 14:25 UTC

    If you have a copy of The Perl Cookbook there's an example of extracting records from a Linux wtmp file using unpack().

      davorg's Data Munging with Perl also has some examples of using pack and unpack to store and retrieve data

      TStanley
      --------
      The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke
        Excellent suggestions. It's good to see that I'm not alone in my shame. Hopefully others will be able to find this thread and have an easier time searching than I did. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://411128]
Approved by castaway
Front-paged by htoug
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-19 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found