Redirecting sql select query result to txt file

Hi ,
I just found you while surfing for the string
'Redirecting sql select query output from within a shell script to txt file/excel file'

Could you find time sending me the code for the above question?
It'll be great help for me.

I have a perl file that calls the sql file (qry.sql). The sql file have my select query in it.

In the perl file i call sqlplus to execute the select statement.
system("sqlplus / \@$SALES_INCENT/qry.sql");

But i'm confused what should be done next to reach my target of sending the output to a tab delimited text and / or excel file.

Please help.

how about using DBI and one of the DBDs to do a database transaction or run a sql query?
for example, if you are using Oracle, you'd need DBI and DBD::Oracle

module Spreadsheet::WriteExcel is a good one to create an Excel file