in reply to Re^3: variable scopes in Excel::Writer::XLSX
in thread variable scopes in Excel::Writer::XLSX

I misused the word 'closure' in my original post. I wanted to assign the workbook to a static variable. I believe that the structure I used is a commonly idiom in Perl for making a variable static.

I never figured out why the error was occurring, but it disappeared when I explicitly called $workbook->close instead of letting the destructor handle it when the program exits. The workbook was also saved correctly.

  • Comment on Re^4: variable scopes in Excel::Writer::XLSX

Replies are listed 'Best First'.
Re^5: variable scopes in Excel::Writer::XLSX (closure)
by Anonymous Monk on May 25, 2013 at 23:42 UTC

    I misused the word 'closure' in my original post. I wanted to assign the workbook to a static variable. I believe that the structure I used is a commonly idiom in Perl for making a variable static.

    Yes that is old idiom, and yes, it is called a closure (Closure on Closures) because func closes over $closure_workbook, a lexical variable declared in outer scope.

    The new idiom is state / use feature qw' state ';

    OTOH, its not really static without this  unless(  $closure_workbook ) { if( @_ ) ... }