From: William James Date: 2008-02-21T23:35:03+09:00 Subject: Re: IP Address to Decimal - is an one-liner possible? On Feb 19, 7:38 pm, Tiago Pinto 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, 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