Naveen_learn has asked for the wisdom of the Perl Monks concerning the following question:

I need to load a set of columns of a table (Oracle) into excel using perl. Below is the main part of the program. ############################
my $file_name="/source_file/source_file.txt"; print LOG "Opening the file \n"; open(SRC_FILE,">$file_name")|| die "Can't open $file_name\n"; print SRC_FILE "USER_ID,USER_NAME,PRIMARY_GROUP,EMAIL \n"; $sql = "SELECT user_id,user_name,primary_group,email from users"; my $sth=$db->prepare($sql); $sth->execute || die "Can't execute the query\n"; while (@row =$sth->fetchrow_array) { print SRC_FILE "$$row[0][0]" \n"; }
##################################### I need to print each column of table in to different columns of the excel.I have to modify this program to get a below output.
USER_ID USER_NAME PRIMARY_GROUP EMAIL abcd arun app_dev arun@abc.com pvad rani consultant rani@abc.com
I have searched the questions of this kind in this site but all in vain. please help me out.

Replies are listed 'Best First'.
Re: Perl Program to load set of columns of table into excel
by code-ninja (Scribe) on Aug 26, 2013 at 09:40 UTC
    please use <code> tags around your code. Also, this question has been repeatedly asked on Perl Monks, search around and you'll find the answer you seek. :)
Re: Perl Program to load set of columns of table into excel
by soonix (Chancellor) on Aug 27, 2013 at 09:02 UTC

    Seconding code-ninja's comment, but perhaps this brings a little more help :-)

    If it is not absolutely necessary to create native Excel files, Excel will happily accept CSV files. These are much easier to handle (plaintext, makes debugging much easier). As you seem to use DBI, perhaps DBD::CSV might come to your rescue, otherwise you could use e.g. Text::CSV.