in reply to Integer IP address to Quad IPv4 address one liner or close to it?

Like this?

print join '.', unpack 'C4', pack 'N', 2130706433;; 127.0.0.1

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW
  • Comment on Re: Integer IP address to Quad IPv4 address one liner or close to it?
  • Download Code

Replies are listed 'Best First'.
Re^2: Integer IP address to Quad IPv4 address one liner or close to it?
by Plankton (Vicar) on Aug 06, 2009 at 18:04 UTC
    Ah Thanks! Would there be a equally straight forward solution for the reverse operation? You ...
    ./somescript.pl 127.0.0.1 2130705433
    ... ?

      You should probably use the functions in Socket who's names I can never remember, but this works for the dotted decimal form:

      print unpack 'N', pack 'C4', split '\.', '127.0.0.1';; 2130706433

      It doesn't work for those obscure forms that only hackers and scammers use: dotted-hex & dotted-octal.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.