johnrcomeau has asked for the wisdom of the Perl Monks concerning the following question:
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!'); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variable scopes in Excel::Writer::XLSX
by toolic (Bishop) on May 25, 2013 at 01:26 UTC | |
by johnrcomeau (Novice) on May 25, 2013 at 03:11 UTC | |
|
Re: variable scopes in Excel::Writer::XLSX
by johnrcomeau (Novice) on May 25, 2013 at 04:35 UTC | |
by johnrcomeau (Novice) on May 25, 2013 at 14:09 UTC | |
by AnomalousMonk (Archbishop) on May 25, 2013 at 19:05 UTC | |
by Anonymous Monk on May 25, 2013 at 15:01 UTC | |
by johnrcomeau (Novice) on May 25, 2013 at 18:22 UTC | |
by Anonymous Monk on May 25, 2013 at 23:42 UTC | |
|
Re: variable scopes in Excel::Writer::XLSX
by 2teez (Vicar) on May 25, 2013 at 13:00 UTC | |
|
Re: variable scopes in Excel::Writer::XLSX
by Anonymous Monk on May 28, 2013 at 09:14 UTC |