in reply to decrementing numbers
Do you need to handle underflow (when the last octet is 0)? If so, would it just wrap to 255, or would you decrement one from the previous octet?
If you need to do the second, one way to solve this is to convert the ipv4 address into a 32 bit number, subtract one, and then convert back. There are network-address functions (I cannot remember or find them right now, grr) for doing this, but pack / unpack is also an option for this.
It is said that "only perl can parse Perl." I don't even come close until my 3rd cup of coffee. --MidLifeXis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: decrementing numbers
by almut (Canon) on Mar 05, 2010 at 18:54 UTC | |
|
Re^2: decrementing numbers
by ddrew78 (Beadle) on Mar 05, 2010 at 20:23 UTC | |
by almut (Canon) on Mar 05, 2010 at 20:47 UTC |