develooper Front page | perl.perl5.porters | Postings from August 2001

RE: pack "b*" isn't dwim enough

Thread Previous | Thread Next
Horsley Tom
August 24, 2001 04:24
RE: pack "b*" isn't dwim enough
Message ID:
> > Because pack "b*" should be the exact opposite of unpack "b*",
> OK. sounds sane.

It may sound sane, but I still remember my first attempts to
understand pack and unpack, and the pod for unpack which mostly
just says "unpack is the reverse of pack" is woefully inadequate.

In many cases, it isn't obvious what "reverse" could mean.

For example, consider "a" and "A". Pack will null or blank
pad strings when you use these formats. What the heck is the
reverse of that? Does unpack remove all trailing nulls and blanks
when I use those formats in unpack, or does it leave all the
padding in the resulting string? Whatever it does, if I use
pack "A" on a string that currently looks like "XXX   ", then
by the time I unpack it, I probably won't have "XXX   " anymore,
so you can't really call it the reverse :-).

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