1. Perl
  2. builtin functions
  3. here

hex function - Convert hexadecimal string to decimal number

You can use the hex function to convert a hexadecimal string to a decimal number.

Hexadecimal to Decimal Conversion

Use the hex function to convert from hexadecimal to decimal.

my $digit = hex('FF');

Hexadecimal FF is decimal 255.

In the example, 'FF' is passed as an argument, but even if 0x is added at the beginning like '0xFF', it will be converted correctly.

A little more about base conversion

You can use oct function to convert from octal to decimal.

If you want to know a little more about binary conversion such as binary, octal, hexadecimal, etc., please refer to the following articles.

Related Informatrion