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