hex Function in Perl

What is hex Function in Perl?


hex Function :

hex() is used to return decimal value for the given hexadecimal value.


hex EXPR

If the first format is used "EXPR" can specify the format of the hexadecimal format, whether it is 0,0x,0b, otherwise it uses a "$" as default.

Example :

#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
print hex '0xae';
print "<br>";
print hex 'aE';
Result :


In the above example, first statement the hexadecimal value is like an expression since "ox" is used, then in the second statement considers the hexadecimal value as a string but both the statements returns the same result "174".

Ask Questions

Ask Question