Perl | ord() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The ord() function is an inbuilt function in Perl that returns the ASCII value of the first character of a string. This function takes a character string as a parameter and returns the ASCII value of the first character of this string. Syntax: ord string Parameter: This function accepts a single parameter 'string' from which we can get an ASCII value. Returns: an integer value which represents the ASCII value of the first character in the string passed to this function as a parameter. Examples: Input: Geeksforgeeks Output: 71 Explanation: The ASCII value of G is 71 Input: WelcometoGFG Output: 87 Explanation: The ASCII value of W is 87 Below programs illustrate the use of ord() function in Perl: Program 1: Perl #!/usr/bin/perl -w # ASCII value of 'G' is printed print(ord('GeeksforGeeks')); Output: 71 Program 2: Perl #!/usr/bin/perl -w # ASCII value of 'W' is printed print(ord('WelcometoGFG')); Output: 87 Comment More infoAdvertise with us Next Article Perl | grep() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-String-Functions Perl-Inbuilt-Functions Similar Reads Perl | oct() Function oct() function in Perl converts the octal value passed to its respective decimal value. For example, oct('1015') will return '525'. This function returns the resultant decimal value in the form of a string which can be used as a number because Perl automatically converts a string to a number in nume 1 min read Perl | log() Function log() function in Perl returns the natural logarithm of value passed to it. Returns $_ if called without passing a value. log() function can be used to find the log of any base by using the formula: Syntax: log(value) Parameter: value: Number of which log is to be calculated Returns: Floating point 2 min read Perl | grep() Function The grep() function in Perl used to extract any element from the given array which evaluates the true value for the given regular expression. Syntax: grep(Expression, @Array) Parameters: Expression : It is the regular expression which is used to run on each elements of the given array.@Array : It is 2 min read Perl | hex Function The hex function in Perl converts the given hexadecimal number ( of base 16 ) into its equivalent decimal number ( of base 10 ). Syntax: hex number Parameters: number: hexadecimal number to be converted Returns: equivalent decimal number of the given hexadecimal number. Example 1: Perl #!/usr/bin/pe 1 min read Perl | List Functions A list in Perl is a collection of scalar values. We can access the elements of a list using indexes. Index starts with 0 (0th index refers to the first element of the list). We use parenthesis and comma operators to construct a list. In Perl, scalar variables start with a $ symbol whereas list varia 4 min read Perl | abs() function This function returns the absolute value of its argument. If a pure integer value is passed then it will return it as it is, but if a string is passed then it will return zero. If VALUE is omitted then it uses $_ Syntax: abs(VALUE) Parameter: VALUE: It is a required number which can be either positi 2 min read Like