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

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

Thread Previous | Thread Next
Dave Storrs
September 19, 2000 07:29
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:

On Mon, 18 Sep 2000, Michael G Schwern wrote:

> I'm sure there are many times when pack should have been used but it
> got hacked together with something else.  The prime example is [...]

	I must admit I'm with Michael on this one.  I've been writing Perl
on and off for two or three years; I consider myself minimally competent
but certainly not great.  I do not understand (un)pack and have never used
them.  Perhaps I could figure it out if I pored over the man pages and the
book and sat and played with it for several hours, but there has never
been sufficient motivation to do so; given that TIMTOWTDI, I have never
*needed* to use (un)pack...and, as a result, I have probably written less
efficient code as a result.

	I guess, if I had to write an explanation of pack/unpack based on
my limited understanding, it would be something like:

	"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

	Is this definition completely off-base?


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