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 18, 2000 09:29
Subject:
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:
Pine.LNX.4.21.0009181221150.7211-100000@airtrout.tregar.com
On Mon, 18 Sep 2000, Michael G Schwern wrote:

> Perhaps someone could attempt to write an explaination of pack and
> unpack in completely Perl terms.  No bits, no ints, no nybbles, no
> IEEE floating point arithmetic, no prior knowledge of C necessary.
> Those are not Perl.  Scalars, arrays, hashes, functions, methods,
> loops, contexts.  These are Perl.

"Describe to me how you use a supermarket shopping-cart in terms of a
hardware store.  Don't mention any words for food.  Just talk about nuts
and bolts."

You've pretty much nailed the primary use of pack/unpack - bridging the
gap between scalars and the various binary formats of Le Monde Cyber.

I used pack recently in order to get Perl talking with Glimpse, a search
engine written in C.  For some bizare reason the Glimpse server won't talk
to you unless you send your PID to it.  As if that weren't strange enough,
it needs your PID split into 4 bytes in reverse order.  If you can think
of a better solution to this problem than pack then by all means propose
it.  I think pack is pretty good at what it does!

Maybe you don't get to know how good it is until you need it?

-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