Welcome to the Monastery | |
PerlMonks |
Re: hex numbersby davido (Cardinal) |
on Jan 14, 2021 at 17:11 UTC ( [id://11126919]=note: print w/replies, xml ) | Need Help?? |
The 0xNNNN notation is a source-code feature. It is parsed at compile-time. So this works:
And this works but you shouldn't use it:
That second example works because even though we've created a string of characters, "0xDEADBEEF", the eval statement evaluates that string as source code, so it gets parsed and compiled when the statement is executed at runtime. This doesn't work:
It didn't work because the string was taken as plain old characters. Since you want to take a string of characters and interpret them as a hex digits you should use the hex function: This is the version you should use:
Dave
In Section
Seekers of Perl Wisdom
|
|