If you have a string that represents a number as another base, you can use the hex() or oct() functions to interpret those numbers correctly.
hex('DEADBEEF') # 3_735_928_559 decimal
hex('0xDEADBEEF') # 3_735_928_559 decimal
oct('0377') # 255 decimal
oct('377') # 255 decimal
oct('0xDEADBEEF') # 3_735_928_559 decimal, saw leading 0x
oct('0b1101') # 13 decimal, saw leading 0b
oct('0b$bits') # convert $bits from binary
\!h # Note: Perl's automatic conversion only works for base-10 numbers