Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Increment of ip address

by monarch (Priest)
on Jun 17, 2005 at 00:54 UTC ( [id://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( '1.2.3.4' ); $ipinc++; print( inttoaddr( $ipinc ) . "\n" );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://467517]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-03-19 06:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found