home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5516 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!convex!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: easy question?: substrings
  5. Originator: tchrist@pixel.convex.com
  6. Sender: usenet@news.eng.convex.com (news access account)
  7. Message-ID: <1992Aug26.224028.29064@news.eng.convex.com>
  8. Date: Wed, 26 Aug 1992 22:40:28 GMT
  9. Distribution: usa
  10. Reply-To: tchrist@convex.COM (Tom Christiansen)
  11. References: <1992Aug26.213516.22813@cbnewse.cb.att.com> <1992Aug26.222821.28341@news.eng.convex.com>
  12. Nntp-Posting-Host: pixel.convex.com
  13. Organization: Convex Computer Corporation, Colorado Springs, CO
  14. X-Disclaimer: This message was written by a user at CONVEX Computer
  15.               Corp. The opinions expressed are those of the user and
  16.               not necessarily those of CONVEX.
  17. Lines: 21
  18.  
  19. From the keyboard of tchrist@convex.COM (Tom Christiansen):
  20. ::All I want to do is to change a string in the format of either
  21. ::    0xffffff00 or ffffff00 into the format
  22. ::    of 255.255.255.0 
  23.  
  24. :    $n = "ffffff00";
  25. :    print join(".", unpack(C4, pack(L, hex($n)))), "\n";
  26. :
  27. :Add quotes around the format strings for old versions of perl.
  28.  
  29. Blech.  Doesn't work on a DECstation.  Byte order foo.  Use this instead:
  30.  
  31.     print join(".", unpack("C4", pack("N", hex($n)))), "\n";
  32.  
  33. --tom
  34.  
  35. -- 
  36.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  37.     There is, however, a strange, musty smell in the air that reminds me of
  38.     something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  39.         --Larry Wall in Configure from the perl distribution
  40.