Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: passing hex argument as string

by batkins (Chaplain)
on Nov 04, 2003 at 02:44 UTC ( [id://304304]=note: print w/replies, xml ) Need Help??


in reply to passing hex argument as string

Well, I'm not sure I'm getting what you're getting at. First of all, the call_f2 sub is entirely superfluous. Now you're comment says that you're trying to print 100. I'm not sure what that means. If you want to print $num in base-10, you should be able to just print it out. If you want to print it in hex (base-16), try:
printf "%x", $chr;
Are you sure it was a book? Are you sure it wasn't.....nothing?

Replies are listed 'Best First'.
Re: Re: passing hex argument as string
by Anonymous Monk on Nov 04, 2003 at 02:52 UTC
    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
      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://304304]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found