biohisham has asked for the wisdom of the Perl Monks concerning the following question:
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#!/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++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a stubborn excel file
by Illuminatus (Curate) on Jun 23, 2009 at 19:53 UTC | |
|
Re: a stubborn excel file
by toolic (Bishop) on Jun 23, 2009 at 20:03 UTC | |
by biohisham (Priest) on Jun 23, 2009 at 21:18 UTC | |
|
Re: a stubborn excel file
by afoken (Chancellor) on Jun 23, 2009 at 19:53 UTC | |
|
Re: a stubborn excel file
by imrags (Monk) on Jun 24, 2009 at 11:02 UTC | |
|
Re: a stubborn excel file
by VinsWorldcom (Prior) on Jun 24, 2009 at 12:22 UTC |