use the DBI module and the respective driver for the type of database. You will probably have to install the DBI module and the driver. You can find them on CPAN.
The CPAN Search Site - search.cpan.org
I can't help with code examples because my SQL knowledge is very limited.