Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: decimal -> hex

by rdfield (Priest)
on Oct 11, 2002 at 09:58 UTC ( [id://204457]=note: print w/replies, xml ) Need Help??


in reply to decimal -> hex

Using pack:
$ip = "127.0.0.1"; print join(".",unpack("H2H2H2H2",pack("c4",split /\./,$ip)));

rdfield

Update: Fixed typo as per blakem's post. I blame the shift key :)

Replies are listed 'Best First'.
Re2: decimal -> hex
by blakem (Monsignor) on Oct 11, 2002 at 10:29 UTC
    I think you've got your nybble order mixed up...
    print join(".",unpack("H2H2H2H2",pack("c4",split /\./,$ip)));

    -Blake

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found