#!/usr/bin/perl

use strict;
use warnings;
use Spreadsheet::WriteExcel;

my ($infile, $line, $worksheet, @cols, $row, $col);
my $workbook = Spreadsheet::WriteExcel->new('output.xls');

while($infile = shift)
{
	$row=0;

	$worksheet = $workbook->add_worksheet($infile);	# Add a worksheet
	open(FIN, "<$infile") || die("Couldn't open $infile"); # open csv

	while(!eof(FIN)) {
		chomp($line=<FIN>);
		@cols=split(/,/, $line);

		for($col=0; $col <= $#cols; $col++) {
			$worksheet->write($row, $col, $cols[$col]);
		}
		$row++;
	}

	close(FIN);
}

