use strict; use warnings; use constant { START_IP_BYTE4 => 2, MAX_IP_BYTE4 => 254, SLEEP => 12 * 3600 }; my @ip = qw(192 168 10 2); $ip[3] = shift || START_IP_BYTE4; while ( 'true' ) { set_ip( @ip ); $ip[3]++; $ip[3] = START_IP_BYTE4 if $ip[3] > MAX_IP_BYTE4; print "Next change: " . localtime( time() + SLEEP ) . "\n"; sleep SLEEP; # floating! } die "oops! $! / $@"; sub set_ip { my @ip = @_; my $ip = join( '.', @ip ); print "Setting local IP to $ip...\n"; print "Load file 'ip$ip[3].txt' ???\n"; #TODO: set local IP }