home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!eff!ckd
- From: ckd@eff.org (Christopher Davis)
- Subject: Bug (or just lack of documentation) for unpack?
- Message-ID: <CKD.93Jan26164858@loiosh.eff.org>
- Sender: usenet@eff.org (NNTP News Poster)
- Nntp-Posting-Host: loiosh.eff.org
- Organization: Electronic Frontier Foundation Tech Central
- Date: Tue, 26 Jan 1993 21:49:03 GMT
- Lines: 33
-
- unpack() appears to grab whole octets, even when using suboctet fields such
- as B4 or H... this should probably be considered a bug, or be documented (I
- couldn't find mention of it in either the camel book or the man page.
-
- This is particularly annoying when trying to use HH to get two separate hex
- digits from a single octet (can you tell I'm working on the unpack stuff
- for the IP packet reader? It was getting the version right, but coming up
- with a zero for the header length, obviously broken...).
-
- I've worked around it by H2'ing into a string and unpacking that, but
- that's less than elegant. (Similar problems are approaching if I want to
- split out the TCP flag bits.)
-
- Example:
- ckd@loiosh ~ > uname -a
- SunOS loiosh.ef 4.1.2 2 sun4c
- ckd@loiosh ~ > perl -v
-
- This is perl, version 4.0
-
- $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
- Patch level: 35
-
- Copyright (c) 1989, 1990, 1991, Larry Wall
-
- Perl may be copied only under the terms of either the Artistic License or the
- GNU General Public License, which may be found in the Perl 4.0 source kit.
- ckd@loiosh ~ > perl -e 'print unpack("HH","d"),"\n"'
- 6
- ckd@loiosh ~ > perl -e 'print unpack("H2","d"),"\n"'
- 64
- --
- * Christopher Davis * <ckd@eff.org> * <ckd@kei.com> * [CKD1] * MIME * RIPEM *
-