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

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

Thread Previous | Thread Next
Sam Tregar
September 19, 2000 07:38
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:
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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About