Perl hex函数
Perl中的hex函数将给定的十六进制数字(以16为基数)转换为等效的十进制数字(以10为基数)。
语法: hex number
参数:
number: 要转换的十六进制数
返回: 所给十六进制数的等效十进制数。
例子 1 :
#!/usr/bin/perl
# Initialising some hexadecimal values for
# the parameter of the hex function
A = "A";B = "B";
C = "1A";D = "2C";
# Calling the hex function
E = hexA;
F = hexB;
G = hexC;
H = hexD;
# Getting the equivalent decimal number
# of the given hexadecimal number
print "E\n";
print "F\n";
print "G\n";
print "H\n";
**
输出**
10
11
26
44
例2:
#!/usr/bin/perl
# Initialising some hexadecimal values and
# Calling the hex function
A = hex D;B = hex af;
C = hex AF;D = hex BF;
# Getting the equivalent decimal number
# of the given hexadecimal number
print "A\n";
print "B\n";
print "C\n";
print "D\n";
输出:
13
175
175
191