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