- 论坛徽章:
- 0
|
本帖最后由 Perl_Er 于 2012-09-18 22:10 编辑
回复 1# shangtian2007 - $ perl -e '$a=010; print $a,"-",oct($a)'
- 8-0
- James_Zhu@WN7X64-JYM9WM1 ~/PERL
- $ perl -e '$a=0x10; print $a,"-",hex($a)'
- 16-22
复制代码 because 010&0x10 are treated as a decimal and perl feed the decimal to oct/hex
Perl understands numbers specified in binary (base-2), octal (base- , and hexadecimal (base-16) notation only when they occur as literals in your programs. If they come in as data—such as by reading from files or environment variables, or when supplied as command-line arguments—no automatic conversion takes place. |
|