eval { ### Catch _any_ kind of failures from the code within ### Enable auto-error checking on the database handle $dbh->{RaiseError} = 1; ### Prepare a SQL statement for execution my $sth = $dbh->prepare( "select distinct `FID_CUST` from `session` where `DAT_END` between `$key` and `$hash{$key}`" ); while (1) { ### Execute the statement in the database $sth->execute(); ### Retrieve the returned rows of data while ( my @row = $sth->fetchrow_array() ) { print "Row: @row\n"; } } }; warn "Monitoring aborted by error: $@\n" if $@;