On Feb 19, 7:38 pm, Tiago Pinto <thpi... / gmail.com> wrote:
> Hi guys,
>
> A friend of mine needs to convert a string containing an IP Address
> (such as "127.0.0.1") to a decimal (that example would translate to
> 2130706433, <http://www.allredroster.com/iptodec.htm> said).

'127.0.0.1'.split('.').zip([3,2,1].map{|n| "*256**#{n}+"}).join
    ==>"127*256**3+0*256**2+0*256**1+1"

eval '127.0.0.1'.split('.').zip([3,2,1].map{|n| "*256**#{n}+"}).join
    ==>2130706433