my $workbook = Spreadsheet::WriteExcel->new("result.xls"); if ( $somevalue == 1 ) { my $workSheet = $workbook->add_worksheet('PASS'); excel_write ( $workSheet,@pageid_pass,@plot_pass ); }