Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Perl 中从键盘读取/输入十六进制数字?
例如,我有一个十六进制数字“3e”,并希望将其从键盘读取到变量中。该变量应存储“3e”的十进制等效值 (62)。
$hex_value = <STDIN>; $decimal_value = hex $hex_value;
解释:
<STDIN>
hex
像往常一样将输入读入标量,例如$foo,然后执行以下操作:
$foo
$bar = hex($foo)