1. Home
  2. Computing & Technology
  3. Perl

Perl chr() & ord() functions - Quick Tutorial
How to use the chr() & ord() functions

From About.com

chr(NUMBER);
ord(CHARACTER);
Perl's chr() and ord() functions are used to convert characters into their ASCII or Unicode values (and vice versa). chr() takes an ASCII or Unicode value and returns the equivalent character, and ord() performs the reverse operation by converting a character to it's ASCII or Unicode value.
print chr(65);
print "\n";
print ord('A');
print "\n";
For more information on encoding, try some of these links:

  1. About ASCII
  2. ASCII Character Code Reference
  3. Perl Encoding with the Encode Module
More Perl Quick Tips
Explore Perl
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Perl
  4. Programming Perl
  5. Perl chr & ord function reference - learn how to use Perl's chr() & ord() functions in this quick tutorial.

©2009 About.com, a part of The New York Times Company.

All rights reserved.