Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: passing hex argument as string

by Anonymous Monk
on Nov 04, 2003 at 02:52 UTC ( [id://304306]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://304306]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found