home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 7998 < prev    next >
Encoding:
Text File  |  1993-01-27  |  1006 b   |  26 lines

  1. Organization: Sponsored account, Chemical Engineering, Carnegie Mellon, Pittsburgh, PA
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!mailgzrz.TU-Berlin.DE!math.fu-berlin.de!ira.uka.de!yale.edu!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!bb3.andrew.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!tm8t+
  3. Newsgroups: comp.lang.perl
  4. Message-ID: <EfNK=9q00YUnF7ZUdI@andrew.cmu.edu>
  5. Date: Tue, 26 Jan 1993 11:11:53 -0500 
  6. From: Tod McQuillin <tm8t+@andrew.cmu.edu>
  7. Subject: Re: How to convert string to hex?
  8. In-Reply-To: <C1Fs2F.BB3@ibeam.intel.com>
  9. References: <C1FnMG.AMB@ibeam.intel.com>
  10.     <C1Fs2F.BB3@ibeam.intel.com>
  11. Lines: 13
  12.  
  13. gweil@ibeam.intel.com (Garry Weil) writes:
  14. > gweil@ibeam.intel.com (Garry Weil) writes:
  15. > >How do I convert "Test" to 0x54 0x65 0x73 0x74 ?
  16. > BTW, I want to separate hex values with ",".
  17.  
  18. How about this:
  19.  
  20. $arg = $ARGV[0];
  21. print join(", ", grep($_=sprintf("0x%x", ord $_), split(//, $arg))),"\n";
  22.  
  23. Works for me.
  24.