in reply to Perl complaining about vars not staying shared
A major shift of code is needed. Move the sub cell_handler to above the parser construction, and remove the name, making it anonymous.
The problem is that named subs are always global. They cannot bind to variables that are currently "in-scope" (in a surrounding function) that may go out of scope (calling cell_handler outside of the surrounding function). In short, global (named) functions cannot be closures.
# Excel parsing my $cell_handler = sub { # cell_handler contents go here. }; my $parse_excel = new Spreadsheet::ParseExcel(CellHandler => $cell_han +dler, NotSetCell => 1); #...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl complaining about vars not staying shared
by dave_the_m (Monsignor) on Jan 27, 2005 at 23:33 UTC |