use warnings; $runcount = 0; while(1) { # see if there is an internet connection running open(IPCONFIG,"ipconfig|") || fatal("Can't fork ipconfig"); $runcount++; print "Good opens so far $runcount\n"; while() { if (/IP Address/) { ($ipaddr) = /(\d+.\d+.\d+.\d+)/; last; } } close(IPCONFIG); sleep 1; } sub fatal { my ($rpt) = @_; print STDERR "Fatal Error Report\n\n"; print STDERR "Reason $rpt\n"; print STDERR "Error $^E\n"; print STDERR "Good opens $runcount\n"; die; } #### $res = `IPCONFIG`; fatal("Call failed") if (!defined $res); $runcount++; ($ipaddr) = ($res =~ /(\d+.\d+.\d+.\d+)/);