in reply to Automatic IP address Generation
use Socket qw( inet_aton inet_ntoa ); sub fr_dotted { unpack 'N', inet_aton @_ ? $_[0] : $_ } sub to_dotted { inet_ntoa pack 'N', @_ ? $_[0] : $_ } my $next = fr_dotted('100.1.3.41'); my $max = fr_dotted('100.1.3.50'); die if $next > $max; my $new = $next++; print(to_dotted($new), "\n");
Update: Had inet_aton where inet_ntoa should have been used.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Automatic IP address Generation
by ajd335 (Novice) on Jul 30, 2008 at 15:59 UTC | |
|
Re^2: Automatic IP address Generation
by ajd335 (Novice) on Jul 30, 2008 at 19:42 UTC | |
by ikegami (Patriarch) on Jul 30, 2008 at 20:21 UTC | |
by ajd335 (Novice) on Jul 30, 2008 at 22:53 UTC | |
by ikegami (Patriarch) on Jul 30, 2008 at 23:45 UTC | |
by ajd335 (Novice) on Jul 31, 2008 at 15:20 UTC | |
by ajd335 (Novice) on Jul 30, 2008 at 20:56 UTC | |
by ikegami (Patriarch) on Jul 30, 2008 at 23:47 UTC |