Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

?: code question

Status
Not open for further replies.

gindelhe

Technical User
May 23, 2002
9
US
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:
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";
}
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top