in reply to adding database values to csv file

Sure, see DBI and Text::CSV, the SYNOPSIS section of documentation always gives sample code