home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!asuvax!ncar!mimbres.cs.unm.edu!constellation!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: unpack and shift idiom?
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Dec17.001810.4070@news.eng.convex.com>
- Date: Thu, 17 Dec 1992 00:18:10 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <1992Dec16.180058.15351@bcars6a8.bnr.ca>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 25
-
- From the keyboard of jsparkes@bcars68a.bnr.ca (Jeff Sparkes):
- :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!
-
- You might try using c2ph to generate all the constants for you.
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
-
- The steady state of disks is full. --Ken Thompson
-