Small function to convert numeric IP address to hex. For example, 255.255.255.0 becomes 0xffffff0.
sub ip2hex{ return "0x" . join ("", map {sprintf "%x", $_} split(/\./,shift)); + }

Replies are listed 'Best First'.
Re: Converting numeric IP address to hex
by AltBlue (Chaplain) on Jan 27, 2001 at 05:45 UTC
    are there too much of splits,map,joins? :)
    s/(\d+)/sprintf "%02X",$1/eg

    --
    AltBlue.

      Ah, but they've been so good to me.

      ----
      Coyote