Dear Monks, I have written this program which is supposed (Update!) TO WRITE TO AN EXCEL file a new set of records, everytime it runs, it works fine the first time I run it, the second time I run it though, it does not append records to the file like it is supposed to, (UPDATE!) I mean it does not update the excel file with new sets of records, in fact it does not add anything and I notice that the excel file size would increase everytime I run the program even though it does not append... I am aware that in programming i am still taking my very first 3 weeks, bt for the past 3 hours I could only come up with this program and got stuck different places, I don't think this is normal :(
#!/usr/local/bin/perl use strict; use warnings; use Spreadsheet::WriteExcel; our %information; open FILE, ">>",'D:\My Code\Records.xls' or die "$!"; binmode FILE; my $workbook=Spreadsheet::WriteExcel->new(\*FILE); my @info = ('Name','Age','Specialization'); #adding a worksheet and writing headings my $worksheet=$workbook->add_worksheet('Personal'); $worksheet -> set_column('A:C',20); for (my $i=0; $i<=$#info;$i++){ foreach my $key(@info){ $worksheet->write(0,$i,$info[$i]); } } #adding records and initializing a row counter since each value in the + hash will have a row print "How many Records do you want to enter?\n"; my $records =<>; chomp $records; my $counter=1; while($counter<=$records){ my $col_counter=0; foreach my $key (@info){ print "Enter $key\n"; $information{$key}=<>; chomp $information{$key}; $worksheet->write($counter, $col_counter, $information +{$info[$col_counter]}); #indexing @info will give $key $col_counter++ if ($col_counter<=$#info); } $counter++; }
any feedback on how to improve this programming style, and on how to make this program does what it is supposed to will be greatly appreciated

In reply to a stubborn excel file by biohisham

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.