From: Ben Bleything Date: 2008-02-20T10:58:12+09:00 Subject: Re: IP Address to Decimal - is an one-liner possible? On Wed, Feb 20, 2008, 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). > > What do you think? There's a way to do this? Is this just a silly question? Check it: require 'ipaddr' IPAddr.new( '127.0.0.1' ).to_i => 2130706433 So, you can do this: superx ~ > ruby -ripaddr -e 'puts IPAddr.new( "127.0.0.1" ).to_i' 2130706433 YEAH. Ben