print hex("0x30"); gives the correct hex to decimal conversion.
What does
print hex(0x30); mean?
The value it’s giving is 72.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
hex()takes a string argument, so due to Perl’s weak typing it will read the argument as a string whatever you pass it.The former is passing
0x30as a string, whichhex()then directly converts to decimal.The latter is a hex number
0x30, which is 48 in decimal, is passed tohex()which is then interpreted as hex again and converted to decimal number 72. Think of it as doinghex(hex("0x30")).You should stick with
hex("0x30").