This is a possible solution. If you want to provide the input file names in the command line read
perlvar and search for 'ARGV'.
use strict;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
my $parser = Spreadsheet::ParseExcel->new(); #Creating Object to Read
+Worksheet
my @files = qw/ Infile1.xls Infile2.xls Infile3.xls Infile4.xls /;
my $write_workbook = new Spreadsheet::WriteExcel('Resultfile.xls');
my $n = 1;
foreach my $file (@files) {
my $parse_workbook = $parser->parse($file);
my $write_worksheet = $write_workbook->add_worksheet("Sheet$n");
if ( !defined $parse_workbook) { die $parser->error(), ".\n"; }
for my $parse_worksheet ( $parse_workbook->worksheets() ) {
my ( $row_min, $row_max ) = $parse_worksheet->row_range();
my ( $col_min, $col_max ) = $parse_worksheet->col_range();
for my $row ( $row_min .. $row_max ) {
for my $col ( $col_min .. $col_max ) {
my $cell = $parse_worksheet->get_cell( $row, $col );
next unless $cell;
my $cell_value = $cell->value();
my $cell_format = $cell->get_format();
$write_worksheet->write($row, $col, $cell_value);
}
}
}
$n++;
}