Hello.
I have the following code to check to make sure an url is up. But I need the ?: or alternative code to return a toggle so I can use and loop to send email so problems can be resolved. Here is the code:
The last print statement is where I would like to return a variable or use an alternative loop structure. Does anyone have suggestions or ideas? I tried to use $t = 1 and $t = 0 instead of is alive or is dead and it always returned $t = 0. I have a feeling it is the way the ?: is processed.
Thanks,
Hal.
I have the following code to check to make sure an url is up. But I need the ?: or alternative code to return a toggle so I can use and loop to send email so problems can be resolved. Here is the code:
Code:
#! /usr/sbin/perl -s
# modules needed
use Watchdog::HTTP;
use Mail::Mailer;
&check_url;
sub check_url
{
# declare Varialbes
$name = "httpd";
$host = "mymiami.muohio.edu";
$port = 80;
# Declare instance
$h = new Watchdog::HTTP($name,$host,$port);
}
&test_url;
sub test_url
{
print $h->id, $h->is_alive ? ' is alive' : ' is dead' , "\n";
}
Thanks,
Hal.