http://www.perlmonks.org?node_id=424263


in reply to Re: Spreadsheet::ParseExcel vs alternative Cell Handler
in thread Spreadsheet::ParseExcel vs alternative Cell Handler

Hey John,

Thanks a lot for the help. Itīs working just perfect now. The only complain is not mine. Itīs Perlīs, that keeps saying all the time:

"Variable "$prev_col" will not stay shared at methods.cgi line 524. Variable "$prev_row" will not stay shared at methods.cgi line 524".

This .cgi is an auxiliar script where Iīve put our code. I call it, as usual, with "require methods.cgi" and call the sub parse_xls() with two arguments - the names of the $infile and $outfile. The conversion is running smoothly, (even with the 15k lines file it was crashing before your cell handler! Great!) but Perl is now complaining with this message every time I run the code. I thought putting a "return 1" would calm down Perl, I say, tell her I am not worried about these variables staying shared, but it didnīt change anything.

Any ideas?

Thanks!

André

Replies are listed 'Best First'.
Re: Perfect now!
by Errto (Vicar) on Jan 22, 2005 at 21:33 UTC
    This is one of Perl's stranger messages, but it is a common one. I assume one of the following is true
    • You are requireing this code from within the body of a subroutine in your main code
    • You are running it with mod_perl under Apache::Registry
    The result is that you are declaring a nested subroutine within another one, and the inner sub accesses a lexical variable declared in the outer one. This is a bad thing, because Perl will not be able to figure out which "instance" of that lexical variable the inner sub should be working with when you call it. Solutions to this problem are explained here.
      Hey, Errto.

      Thatīs the first one, in fact! Thanks for the help!

      André

Re: Perfect now!
by Tanktalus (Canon) on Jan 22, 2005 at 20:31 UTC

    Checking out perldoc perldiag can be really handy for these. As you don't have 524 lines of code here, I can't really be sure what it's referring to, but I find the diagnostic info to be incredibly useful. So useful that our coding standards say "use diagnostics" must be in our perl code, up with "use strict" and "use warnings".