I just downloaded and started using Excel::Writer::XLSX and have written some buggy code. I have isolated the problem down to a few simple lines. The following script will produce an error when provided an argument so that it uses the $closure_workbook variable. (I can't remember the term for this kind of variable that is scoped outside the current block, but I thought it was a "closure".) The error is
Use of uninitialized value in numeric eq (==) at C:/strawberry/perl/site/lib/Excel/Writer/XLSX/Workbook.pm line 839 during global destruction.
Without the argument, the script uses the $workbook variable, runs fine and saves the workbook as expected.
I am running this on Strawberry Perl 5.16.2 on Windows 8. Excel::Writer::XLSX is version 0.67. Please help!
Thanks, John
The script:
use strict; use Excel::Writer::XLSX; &func(@ARGV); { my $closure_workbook; sub func { my $book; if (@_) { $book = $closure_workbook = Excel::Writer::XLSX->new( 'perl_bu +g.xlsx' ); } else { my $workbook = Excel::Writer::XLSX->new( 'perl_good.xlsx' ); $book = $workbook; } my $worksheet = $book->add_worksheet(); $worksheet->write(0, 0, 'Hi Excel!'); } }
In reply to variable scopes in Excel::Writer::XLSX by johnrcomeau
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |