in reply to How do I convert each character in a string to its ASCII value ?

From the Perl Cookbook:
Use pack and unpack. Here is an example (recipe 1.4):
@ascii_character_number = unpack( "C*", "sample" ); print "@ascii_character_number\n"; #prints 115 97 109 112 108 101 $word = pack( "C*", @ascii_character_numbers ); $word = pack( "C*", 115, 97, 109, 112, 108, 101 ); # same print "$word\n"; #prints sample

-loc

  • Comment on Re: How do I convert each character in a string to its ASCII value ?
  • Download Code