Perl hex Function


Advertisements


Description

This function interprets EXPR as a hexadecimal string and returns the value, or converts $_ if EXPR is omitted.

Syntax

Following is the simple syntax for this function −

hex EXPR

hex

Return Value

This function returns numeric value equivalent to hexa in scalar context.

Example

Following is the example code showing its basic usage −

#!/usr/bin/perl

print hex '0xAf'; # prints '175'
print "\n";
print hex 'aF';   # same

When above code is executed, it produces the following result −

175
175

perl_function_references.htm

Advertisements