|Welcome to the Monastery|
I've often felt that base manipulation was one of perl's shortcomings -- not because it can't do it just because it's difficult and, as you point out, the functions work in reverse.
I don't want to see your magic function because we'd then have:
which I'm sure you'll agree is just wrong.
I'd prefer that the existing functions did what they appear to do: hex() returns a hexidecimal representation of the input data and oct() returns an octal representation. Similarly a bin() function should return a binary representation.
As changing now would be an absolute backward-compatability nightmare, I'd suggest using the full names for decimal-to-base-n conversion: hexidecimal(255) eq 'FF'.
We might also include generic base manipulator, but it's probably more a loadable (module) function (the functionality below probably already exists in a module, I haven't checked):
An OO module could even be more transparent:
After all that, my main point is that I absolutely agree that those two functions are completely non-intuitive.
"Get real! This is a discussion group, not a helpdesk. You post something, we discuss its implications. If the discussion happens to answer a question you've asked, that's incidental." -- email@example.com in clpm