- Perl ›
- builtin functions ›
- here
ord function - Convert ASCII characters to numbers
You can use the ord function to convert ASCII code characters to numbers, which are internal representations. This is the opposite of chr function.
my $ascii_code = ord $char;
Ord function example
This is an example that uses the ord function to convert ASCII code characters to numbers, which is an internal representation.
use strict; use warnings; print "(1) Convert ASCII code characters to internal table\current numbers.\n"; # In the ASCII character code, 65, 66, and 67 correspond to'A', ' B', and'C', respectively. my $A = 'A'; my $B = 'B'; my $C = 'C'; print ord($A) . "\n"; print ord($B) . "\n"; print ord($C) . "\n";