in reply to Re: passing hex argument as string
in thread passing hex argument as string

yes I am familiar with printf function. But I can not do that. Beccause the function that takes $chr is *FIXED*, and I can not change it. So what I want is a function that: # takes a hex number 0xff # returns string "ff" and NOT 255

Replies are listed 'Best First'.
Re: Re: Re: passing hex argument as string
by ysth (Canon) on Nov 04, 2003 at 03:37 UTC
    That's what
    sprintf("%x", $hexnum)
    does. If $hexnum is 0xdeadbeef, the sprintf will return "deadbeef". (Use %X instead of %x if you want "DEADBEEF".)

    (updated to correctly say sprintf instead of printf)