Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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( '1.2.3.4' ); $ipinc++; print( inttoaddr( $ipinc ) . "\n" );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://467517]
help
Chatterbox?
[stevieb]: one of my long-running Perl procs crashes with a segfault (because it wraps C code) is crashing after an hour or so... seeing if wrapping the cli call with valgrind will produce something useful

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-04-29 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.