I've written a daemon process, that regularly fetches some urls from the net. When my ppp-link goes down "ifdown ppp0" and I reconnect to a different provider "ifup ppp1" (different IP-address and nameservers), my script keeps failing to fetch those urls. A simple restart of my script makes it work again.
I could reduce the script to:
use Net::Ping;
while (1) {
my $p = Net::Ping->new(udp);
if $p->ping($host) {
print "success\n";
} else {
print "failed\n";
}
undef $p;
sleep 3;
}
or
use LWP::Simple;
while (1) {
my $content = get($url);
if (defined $content) {
print "success\n";
} else {
print "failed\n";
}
sleep 4;
}
How can I fix my script, so I don't have to restart it, if I need to change my ppp-link?