#!/usr/bin/perl use strict; use warning; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; my $path = '/abc'; my $te = "$path/texas"; my $mi = "$path/michigan"; my $ha = "$path/hawaii"; my $fl = "$path/florida"; my $ke = "$path/kentucky"; my $excl = Spreadsheet::WriteExcel->new("$path/one.xls"); die "Cannot create new Excel file: $!" unless defined $excl; my $parser = new Spreadsheet::ParseExcel; for my $source ( "$te/te.xls", "$mi/mi.xls", "$ha/ha.xls", "$fl/fl.xls", "$ke/ke.xls" ){ my $book = $parser->parse($source); if ( !defined $book ) { die $parser->error(), ".\n"; } my $file; my $source = $book->add_worksheet($source); if ($source =~ /1/) { $file = $excl->add_worksheet('TX'); } elsif ($source =~ /2/) { $file = $excl->add_worksheet('MI'); } elsif ($source =~ /3/) { $file = $excl->add_worksheet('HI'); } elsif ($source =~ /4/) { $file = $excl->add_worksheet('FL'); } elsif ($source =~ /5/) { $file = $excl->add_worksheet('KY'); } my $all = $file; for my $parse_worksheet ( $excl->source() ) { my ( $row_min, $row_max ) = $source->row_range(); my ( $col_min, $col_max ) = $source->col_range(); for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $cell = $source->get_cell( $row, $col ); next unless $cell; $all->write( $row , $col, $cell->unformatted ); } } } } $excl->close(); #### The code is now clean without errors. I have tried to export the new file, but the excel file has only one sheet with Empty data. sad I did tried to export one of the xls file, and yes Im getting the one sheet with contents. Can anyone please help me out? I'm still new to Perl, so I don't have any idea what I did wrong in the code.