#!perl use strict; use warnings; use Spreadsheet::WriteExcel; use Text::CSV_XS; my $csv = Text::CSV_XS->new({ binary => 1, sep_char => ',', eol => "\n"}); my $xlsfile = 'c:/temp/xyz_stat1.xls'; my $workbook = Spreadsheet::WriteExcel->new($xlsfile) or die $!; my $num_files = $ARGV[0] || 0; for my $k (1..$num_files){ my $csvfile = $ARGV[$k]; print "Opening $csvfile .. "; open my $fh, '<', $csvfile or die "Cannot open $csvfile : $!"; my $sheet = $workbook->add_worksheet('sim_'.$k); my $ar = $csv->getline_all($fh); $sheet->write_col(0,0,$ar); close $fh; print scalar (@$ar). " lines read into sheet sim_$k\n"; } $workbook->close; print "$xlsfile created\n";