in reply to Global variables issue in spreadsheets

Using an earlier Perl

perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 33 registered patches ... Binary build 819 [267479] provided by ActiveState http://www.ActiveSta +te.com Built Aug 29 2006 12:42:41)
...and

Spreadsheet::WriteExcel v 2.25

...and specifying a location (not INC) for config.pl, I see a rather different failure; namely:

 (in cleanup) Can't call method "isa" on an undefined value at C:/Perl/site/lib/Spreadsheet/WriteExcel/Workbook.pm line 1366 during global destruction.

...and a zero-byte simple.xls created in CWD.

Version differences may account for the diff... but for a stab in the dark (because no other suggestions have been offered yet), you might want to tell us WHERE config.pl is stored and what version of S::WE you're using. You might also find it worthwhile to check for bug reports on your version of S::WE.

Replies are listed 'Best First'.
Re^2: Global variables issue in spreadsheets
by syniperl (Novice) on Jan 05, 2011 at 00:16 UTC

    I used perl 5.10.1 built for i486-linux-gnu-thread-multi. Ubuntu OS. The config.pl and the main.pl are in the same folder.

    Tried the same on a pc having perl 5.12.2 built for x86_64-linux-thread-multi and same result

      • Does your require line in main.pl use the full path to config.pl? I may be wrong, but I believe it should.
      • From what directory do you execute main.pl?
      • Please clarify your statement about using my <$var names>. Do you mean you're not using the config.pl and declaring my $workbook and my $worksheet in main.pl or something else?
      • Since the code you've shown matches what's in the doc for my copy of S::WE (with the minor exception -- at line 15 -- of providing "0" values directly instead of by assigning "0" values to $col and $row), the possibilities include:
        1. Borked installs for both copies (you do have two, right?) of S:WE (a longshot, IMO)
        2. Something you haven't shown/told us (see my prior questions)
      • You might also want to look at lines around 1545-1546 in Workbook.pm to see if that section of the code provides any clues.

      Update: And why, except for the sake of a learning experience, are you using a separate config.pl merely to declare two stock variables? That seems to me more than just a few degrees off vertical; an unnecessary bit of complexity or mis-direction.

        Thanks for the detailed comments. Please see my response below

        Does your require line in main.pl use the full path to config.pl? I may be wrong, but I believe it should.

        Comment:This part is extracted from a working project. For simplicity I gave you the piece of code that is broken. The path is fine

        From what directory do you execute main.pl?

        Comment:Both the scripts are in the same directory and I execute the code from the same directory

        Please clarify your statement about using my <$var names>. Do you mean you're not using the config.pl and declaring my $workbook and my $worksheet in main.pl or something else?

        Comments: Yes you are right I am not using the config.pl and instead declaring within main.pl. Sorry I was saving space in the initial post but ended up not giving too many details.

        Since the code you've shown matches what's in the doc for my copy of S::WE (with the minor exception -- at line 15 -- of providing "0" values directly instead of by assigning "0" values to $col and $row), the possibilities include: Borked installs for both copies (you do have two, right?) of S:WE (a longshot, IMO) Something you haven't shown/told us (see my prior questions)

        You might also want to look at lines around 1545-1546 in Workbook.pm to see if that section of the code provides any clues.

        I checked the code and it breaks in these statements next unless $sheet->{_sheet_type} == 0x0000; next unless $sheet->_prepare_images(); I tried to print these two values and it is '0' both while using config.pl and while using the 'my variable'.

        Update: And why, except for the sake of a learning experience, are you using a separate config.pl merely to declare two stock variables? That seems to me more than just a few degrees off vertical; an unnecessary bit of complexity or mis-direction.

        Comment: I have a bigger working project and I am just introducing the spread sheet into it. So I need the global variable working since it will be used by other files and other processes also which will have access to the config file.