http://www.perlmonks.org?node_id=1056242

devbond has asked for the wisdom of the Perl Monks concerning the following question:

I want to declare workbook outside the subroutine because i want to use it in other subs also .but the following code is not working for me. Please Help.
#!/usr/bin/perl use warnings; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $workbook; my @s; $Month=Sept; sub create_excel { $workbook = Spreadsheet::WriteExcel->new('FAISTATS_'."$Month".'.xls'); for ( $i=1;$i<=8;$i++) { $s[$i] = $workbook->add_worksheet( "cpzea0".$i."a0001" ) ; } $s[9] = $workbook->add_worksheet( "WEEKLY" ) ; $s[10] = $workbook->add_worksheet( "MONTHLY" ) ; } create_excel();