如何解决这个数据库编程问题?

如何解决这个数据库编程问题?

我是新手,希望大家多多指点。
我想要实现的功能如下:
怎样连接数据库,并把给定的一个数值$t与数据库中$table表第一个字段的值$a和第二个字段的值$b进行对比,如果数值$t在$a和$b之间,则输出$table表第三个字段的值$c。

这个过程怎样完成?希望能详细点,不胜感激!

就告诉我如何就连接数据库,如何操作表就可以了,谢谢!
perldoc DBI
#!/usr/bin/perl
# Fig. 15.18: fig15_18.pl
# Program to query a database and display the contents in a table  

use warnings;
use strict;
use DBI;
use DBD::ODBC;

my $dbh = DBI->connect( "DBI:ODBC:employeeDB", "", "" ) or
   die( "Could not make connection to database: $DBI::errstr" );

my $sth = $dbh->prepare( q{ SELECT * FROM employee } ) or
   die( "Cannot prepare statement: ", $dbh->errstr(), "\n" );
     
my $rc = $sth->execute() or
   die( "Cannot execute statement: ", $sth->errstr(), "\n" );

my @array;

while ( @array = $sth->fetchrow_array() ) {
   write();
}

# Check to see if fetch terminated early
warn( $DBI::errstr ) if $DBI::err;

$sth->finish();
$dbh->disconnect();

format STDOUT =  
@<<<<<<@<<<<<<<<<@<<<<<<<<<<@<<<<<@<<<<<<<<<<<<
$array[ 0 ], $array[ 1 ], $array[ 2 ], $array[ 3 ], $array[ 4 ]
.


###########################################################################
#  (C) Copyright 2001 by Deitel & Associates, Inc. and Prentice Hall.     #
#  All Rights Reserved.                                                   #
#                                                                         #
#  DISCLAIMER: The authors and publisher of this book have used their     #
#  best efforts in preparing the book. These efforts include the          #
#  development, research, and testing of the theories and programs        #
#  to determine their effectiveness. The authors and publisher make       #
#  no warranty of any kind, expressed or implied, with regard to these    #
#  programs or to the documentation contained in these books. The authors #
#  and publisher shall not be liable in any event for incidental or       #
#  consequential damages in connection with, or arising out of, the       #
#  furnishing, performance, or use of these programs.                     #
###########################################################################
while ( @array = $sth->fetchrow_array() ) {
   write();
}
write()是不是把记录写进内存?