Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Increment of ip address

by monarch (Priest)
on Jun 17, 2005 at 00:54 UTC ( #467517=note: print w/replies, xml ) Need Help??

in reply to Increment of ip address

In thread perl ipcalc oneliners I posted some quick math subroutines you can use for converting your IP address into a number and back for arithmetic purposes without relying on any other module.

Try using:

sub addrtoint { return( unpack( "N", pack( "C4", split( /[.]/,$_[0] ) ) ) ) }; sub inttoaddr { return( join( ".", unpack( "C4", pack( "N", $_[0] ) ) ) ) }; my $ipinc = addrtoint( '' ); $ipinc++; print( inttoaddr( $ipinc ) . "\n" );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://467517]
[Your Mother]: shmem is also quite well. The rest of you, horrible!!!!
[shmem]: me sinks back into the armchair by the fire, smikes a pope and calls this a day.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-03-19 20:37 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.