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

Ah Thanks! Would there be a equally straight forward solution for the reverse operation? You ...
./somescript.pl 127.0.0.1 2130705433
... ?
  • Comment on Re^2: Integer IP address to Quad IPv4 address one liner or close to it?
  • Download Code

Replies are listed 'Best First'.
Re^3: Integer IP address to Quad IPv4 address one liner or close to it?
by BrowserUk (Patriarch) on Aug 06, 2009 at 18:43 UTC

    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.