home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 8016 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.1 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!paladin.american.edu!howland.reston.ans.net!usc!cs.utexas.edu!sun-barr!olivea!sgigate!sgiblab!adagio.panasonic.com!chorus.mei!sweet.mei!alps.msr.mei!alps!shiji
  2. From: shiji@msr.mei.co.jp
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: How to convert string to hex?
  5. Message-ID: <SHIJI.93Jan27133115@alps.msr.mei.co.jp>
  6. Date: 27 Jan 93 04:31:15 GMT
  7. References: <C1FnMG.AMB@ibeam.intel.com>
  8. Sender: news@msr.mei.co.jp
  9. Organization: Matsushita Soft-Research,Inc.,Osaka, Japan
  10. Lines: 22
  11. In-Reply-To: gweil@ibeam.intel.com's message of 26 Jan 93 08:23:03 JST
  12. Nntp-Posting-Host: alps
  13.  
  14. In article <C1FnMG.AMB@ibeam.intel.com> gweil@ibeam.intel.com (Garry Weil) writes:
  15.  
  16.      $@!U(JHow do I convert "Test" to 0x54 0x65 0x73 0x74 ?
  17.  
  18.  Something like as follows ? 
  19.  
  20. #! /usr/local/bin/perl
  21. while (<>) {
  22.     chop;
  23.     split(//);
  24.     for $c (@_) {
  25.         $c = sprintf("0x%02x", ord $c);
  26.     }
  27.     print "@_\n";
  28. }
  29.  
  30.  
  31. ---
  32.  Toshiaki Shiji
  33.  Software Development Department 5
  34.  Matsushita Soft-Research, Inc.            Email: shiji@msr.mei.co.jp
  35. ---------------------------------------------------------------------------
  36.