in reply to Xls reader

In addition to haukex good comment, look at this line:

for(my $k=2; $k<521754; $k++)

In the case that your Excel sheet does not have 521754 rows, consider using $Sheet2->UsedRange->Rows instead:

Update: See the corrections by haukex below!

my $used_rows = $Sheet2->UsedRange->Rows(); for my $k (2..$used_rows) { }

Replies are listed 'Best First'.
Re^2: Xls reader
by haukex (Archbishop) on Jan 02, 2019 at 10:35 UTC
    $Sheet2->UsedRange->Rows

    Unfortunately I don't think that works, since Rows still returns an object, and in numeric context returns the memory address. Also, AFAIK, if the sheet has empty rows and columns at the beginning, the UsedRange can begin somewhere other than A1 - what I've been using is something like this:

    my $UsedRows = 0+$Sheet->UsedRange->{Rows}->{Count}; my $FirstRow = 0+$Sheet->UsedRange->Rows(1)->{Row}; my $LastRow = $FirstRow + $UsedRows - 1; my $UsedCols = 0+$Sheet->UsedRange->{Columns}->{Count}; my $FirstCol = 0+$Sheet->UsedRange->Columns(1)->{Column}; my $LastCol = $FirstCol + $UsedCols - 1;