use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; $xl->{SheetsInNewWorkbook} = 5; my $wb = $xl->Workbooks->Add; $wb->Sheets(4)->{Name} = 'del'; $wb->Sheets(5)->{Name} = 'dell'; my @excel_del_sheets = ("del", "Sheet1", "Sheet2", "Sheet3"); for (my $shtNo = $wb->Sheets->{Count}; $shtNo > 0; $shtNo--) { my $shtName = $wb->Sheets($shtNo)->{Name}; if (grep(/^$shtName$/, @excel_del_sheets)) { $wb->Sheets($shtNo)->Delete; } }