home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7458 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.1 KB  |  31 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!torn!nott!bnrgate!bcars6a8!bcars68a!jsparkes
  3. From: jsparkes@bcars68a.bnr.ca (Jeff Sparkes)
  4. Subject: unpack and shift idiom?
  5. Message-ID: <1992Dec16.180058.15351@bcars6a8.bnr.ca>
  6. Sender: usenet@bcars6a8.bnr.ca (Use Net)
  7. Nntp-Posting-Host: bcars68a
  8. Organization: Bell-Northern Research Ltd., Ottawa
  9. Date: Wed, 16 Dec 1992 18:00:58 GMT
  10. Lines: 19
  11.  
  12. I'm reading binary data from a network stream.  I've accumulated the data in
  13. a variable called $data, and am taking it apart in chunks.  The code
  14. looks like:
  15.     @output = unpack("L4S6", $data);
  16.     $data = substr($data, 28);
  17.     @names = unpack("A20", $data);
  18.     ???
  19.  
  20. I'm concerned by the need to use a constant as the arg to substr, especially
  21. since I calculated it wrong the first time, and it took me a while to find.
  22. This gets especially hairy when I pull strings out of the data stream, since
  23. I don't know how many bytes to skip after unpacking A strings because some
  24. stripping occurs.
  25.  
  26. Please tell me I'm missing something!
  27. --
  28. --
  29. Jeff Sparkes jsparkes@bnr.ca    Bell-Northern Research, Ottawa (613)765-2503
  30. You know, a muffin can be *very* filling.
  31.