The driver code: guided tour
Part 3: Main loop
while(1) {
$mech = WWW::Mechanize->new;
$pinger = Net::Ping->new;
for( keys %$bit_assignments ) {
if( ref( $bit_assignments->{$_} ) ) {
$port->set_bit( $_, &{$bit_assignments->{$_}} )
}
elsif( $bit_assignments->{$_} =~ /^http/ ) { # website still there?
$mech->get( $bit_assignments->{$_} );
$port->set_bit( $_,$mech->success );
}
elsif( $bit_assignments->{$_} =~ /^\d+/ ) { # ping
$port->set_bit( $_, $pinger->ping( $bit_assignments->{$_} ) );
}
else { die "WOAH - what the heck is $bit_assignments->{$_} ??"; }
}
$mech = undef; # no need to hang on to this while we sleep
$pinger = undef;
sleep( $sleep_duration );
}