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

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

Thread Previous | Thread Next
Michael G Schwern
September 18, 2000 11:17
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:
On Mon, Sep 18, 2000 at 12:32:08PM -0400, Sam Tregar wrote:
> "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."

"When shopping for tools, a shopping-cart is the thing you carry your
 tools in before paying for them.  It rolls around on wheels and keeps
 one hand free for more important things like holding your beer."

You can do it!  While it seems "food" and "supermarket" are critical
to the understanding of a shopping-cart, they're really just
incedental.  I'm saying the same thing about un/pack!

If I grok'd the bastards, I'd write the explaination myself.

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

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
fixed-width data parsing.  Most people reach for substr() or a regex,
but the best solution (as pointed out in perlfaq5) is pack.  Yet it
still remains obtuse and I'm largely cargo-culting when I use it.

Think about a user who does not understand regexes.  They typically
have no idea what they're missing.


Michael G Schwern
Just Another Stupid Consultant                      Perl6 Kwalitee Ashuranse
<GuRuThuG> make a channel called Perl, and infest it with joking and doesnt make alot of sense.

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