D
dn_perl
I run a perl script which uses an infinite loop.
I would like to incorporate checks which allow me to exit
the infinite loop if the database is brought down.
The current script is :
----------------
$dbh = DBI->connect or die ;
while(1) {
do certain things ;
if( str eq 'this' ) { # check one
last;
}
# I want to add check # two here
sleep 100 ;
}
$dbh->disconnect ;
----------------
What should check # two do?
Would the following statement work?
if( not $dbh ) { last ; }
I don't know how $dbh is affected when the databse is brought down.
And I have no way of knowing it right now.
===========================
I would like to incorporate checks which allow me to exit
the infinite loop if the database is brought down.
The current script is :
----------------
$dbh = DBI->connect or die ;
while(1) {
do certain things ;
if( str eq 'this' ) { # check one
last;
}
# I want to add check # two here
sleep 100 ;
}
$dbh->disconnect ;
----------------
What should check # two do?
Would the following statement work?
if( not $dbh ) { last ; }
I don't know how $dbh is affected when the databse is brought down.
And I have no way of knowing it right now.
===========================