home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 8006 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.7 KB  |  45 lines

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