hex EXPR
returns the number of which EXRP
is a hexadecimal representation with or without leading 0x
or x
. #!/usr/bin/perl use warnings; use strict; print(hex('10') + hex('0x1A')); # 42
#!/usr/bin/perl use warnings; use strict; my $x = '48656c6c6f20576f726c6421'; for (my $i = 0; $i<length($x); $i+=2) { my $a = chr(hex(substr($x, $i, 2))); print $a; } print "\n";