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

My excel writing last element twice in consecutive rows. i have an excel from where its reading below

Reading 2 rows like below |900000001| |900200001|

Writing 3 rows instead of 2

Sandy Candy Sandy.Candy@abc.com AD Chandy Ganny Chandy.Ganny@nbc.com AD Chandy Ganny Chandy.Ganny@nbc.com AD

if ($reecode ne "404") { for my $i (0..$#resext) { $response = $resext[$i]{id}; #$reslogin = $resext[$i]{login}; $resfn = $resext[$i]{firstName}; $resln = $resext[$i]{lastName}; $resdsrip = $resext[$i]{email}; $resuser = $resext[$i]{type}; $worksheet1->write($r, 0, $resfn); $worksheet1->write($r, 1, $resln ); $worksheet1->write($r, 2, $resdsrip); $worksheet1->write($r, 3, $resuser); $r += 1; } }

Replies are listed 'Best First'.
Re: My EXCEL.Writter writing last element twice in consecutive rows.
by GrandFather (Saint) on Dec 22, 2020 at 20:10 UTC

    You haven't given us enough code to understand the context and check that variables (@resext in particular) contain expected stuff. I suggest you replace the Excel related lines and replace them with print statements to make debugging easier and to be able to create a test script we can run.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      I have fixed the issue and the code had curly brace placement issue for an if condition . The curly brace termination should be replaced from top position to bottom resolved this issue.