Perl Programming/Keywords/ord

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: or Keywords Next: our

The ord keyword[edit | edit source]

ord returns the number associated with the EXPRESSION. If EXPRESSION is an empty string, the function returns 0. Without NUMBER, the contents of $_ are used.

ord is the reverse of chr.

Syntax[edit | edit source]

  ord EXPRESSION
  ord

Examples[edit | edit source]

The lines
#!"C:/Programms/Perl/site/bin"
use 5.10.0;

$character = 'A';

say "character = '" . $character, "' corresponds to the value of " . ord $character;
returns
number = 65 corresponds to the code 'A'
character = 'A' corresponds to the value of 65

See also[edit | edit source]

Previous: or Keywords Next: our