What's going wrong is that you are assigning a numeric value to $binaddr, but treating it as though it contained the string '100010', while it actually has the value 34, so oct is being asked to convert the string '0b34'.
If you quote the 100010, then it will work as expected:
#!perl $binaddr = '100010'; $hexaddr = sprintf("%x", oct("0b$binaddr")); print $hexaddr;
In reply to Re: Converting Binary to hex
by RonW
in thread Converting Binary to hex
by Himaja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |