breadbonda has asked for the wisdom of the Perl Monks concerning the following question:

This is code snippet Where i am reading a xls file called delaytemplate

my $parser_delaytemplate_oop = Spreadsheet::ParseExcel::Save +Parser->new(); my $parser_delaytemplate_handler = $parser_delaytemplate_oop->Pars +e($open_thisoo) or die "Unable to open $open_thisoo\n, $!"; my $delaytemplate_me = $parser_delaytemplate_handler->worksheet(0) +; for(my $i = 0 ; $i < 1000000 ; $i++) { my $parser = $delaytemplate_me->get_cell(0, $i+1); if($parser) { $corners_xls[$counter_corners_xls++]= $parser->value(); } else { last; } }

This snippet is in a subroutine which is called around 500 to 3000 times. When i am calling this code snippet for 500 times, there are no errors. When i am calling this code snippet for more times like around 3000, then all the values are showing up as unintialized, despite me reading the same xls file in both cases. In each subroutine call, I am reading the same xls file multiple times. Does my library provide any limitations on number of times I can read the same xls file?

Replies are listed 'Best First'.
Re: xls file number of reads limit?
by choroba (Cardinal) on Oct 07, 2020 at 16:58 UTC
    What's the scope of @corners_xls and $counter_corners_xls? Aren't you creating an array of 3_000_000_000 elements?
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: xls file number of reads limit?
by perlfan (Parson) on Oct 08, 2020 at 00:20 UTC
    Based on your logic, is it possible that you've hit a cell that has no data and therefore $parser is in fact undef - or falsy (e.g., 0, q{}, -1, etc)? This singular situation would force you to leave your loop via last;. And expecting anything in the array for that cell and beyond would come back as undefined.

    Update: *fixed*

      -1 is not false
        fixed

      i myself have generated the spreadsheet it is reading, and there are no undef cells in the reading spreadsheet

Re: xls file number of reads limit?
by wazat (Monk) on Oct 10, 2020 at 21:01 UTC

    I don't have an answer to the question you asked. I haven't used Spreadsheet::ParseExcel in a long time, and even then the only frill I used was a custom CellHandler

    I see you are using Spreadsheet::ParseExcel::SaveParser.

    Are you modifying the spreadsheet? If so, could there be a problem related to your updates to the spreadsheet?

    If you are only reading the spreadsheet, why don't you create the parser via Spreadsheet::ParseExcel->new()?