[thelist] can someone explain perl's pack/unpack to me?

Dean Mah dmah at members.evolt.org
Tue Oct 29 22:11:01 CST 2002

If you just got 36 as the return for an entire string of data, it
sounds like you are returning the scalar value of unpack.  If you are
assigning the return of the function to a variable, try using a list
rather than a scalar.

Also, is the data in the file binary or ASCII representations of the
data?  You might want to try asking the question at perlmonks.org.


On Tue, Oct 29, 2002 at 12:26:01PM -0500, Benjamin C. Varadi wrote:
> http://www.sleepycat.com/docs/ref/dumpload/format.html
> "If the backslash character precedes another backslash character, it means
> that a literal backslash character occurred in the key or data item. If the
> backslash character precedes any other character, the next two characters
> must be interpreted as hexadecimal specification of a single character; for
> example, \0a is a newline character in the ASCII character set.
> The problem is, I know enough about perl to know that unpack should be used,
> but not enough to know how.  I tried reading the file in line by line, &
> unpacking each line (tried h2 & A2), and both ways got "36" as the output
> for the line.
> I realize my lack of understanding could make this a really unpleasant
> thread to follow.  Can someone just point me towards references for dealing
> with files, pack & unpack that may be a little easier to follow than the
> manual pages?  I don't want to learn the entire language, just wanna come up
> with a quick hack.
> -BEN
> ----- Original Message -----
> From: "Dean Mah" <dmah at members.evolt.org>
> To: <thelist at lists.evolt.org>
> Sent: Tuesday, October 29, 2002 10:38 AM
> Subject: Re: [thelist] can someone explain perl's pack/unpack to me?
> > You need to know the format of a dbm dump to know how to unpack it.
> > What are you using now as the template to unpack?  Are you sure that
> > is how the binary data is formatted?

More information about the thelist mailing list