develooper Front page | perl.perl6.language | Postings from September 2000

Re: pack/unpack is damn unperlish. Explain them as Perl.

Thread Previous | Thread Next
From:
Sam Tregar
Date:
September 19, 2000 07:38
Subject:
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:
Pine.LNX.4.21.0009191033580.8765-100000@airtrout.tregar.com
On Tue, 19 Sep 2000, Dave Storrs wrote:

> 	"Unpack takes binary data in some particular format and
> disassembles it, assigning various pieces of it to variables according to
> formatting that you supply.  Pack does the opposite, using your supplied
> formatting to crunch Perl scalar variables into binary data that is
> represented in some specific way.  The binary data used by (un)pack will
> belong to exactly one type of C numeric variable, meaning that it will be
> limited in what kinds of numbers it can store and how it will represent
> them."
> 
> 	Is this definition completely off-base?

You were doing fine until the last sentence.  I'm not 100% sure what it
means but I'm pretty sure its not right.  pack() and unpack() do a lot
more than just C numerics - they do Unicode, network byte ordering, hex
strings, simple compression and null packing.

I wouldn't suggest that every Perl geek should know pack() and unpack().  
Still, when you need it you'll be glad its there.

-sam



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About