foreach my $row ($sheet->{MinRow}+18..$sheet->{MaxRow}){ if ($sheet->{Cells}[$row][2]->{Val} eq "SYSTEM") {$comment = $sheet->{Cells}[$row-2][2]->{Val}}; #This syntax returns the right value if ($sheet->{Cells}[$row][3]->{Val} eq "UPGRADE SOLUTION") {$upgrade=1} else {$upgrade=0}; # This syntax always returns 0 even when the match should return a 1 if ($sheet->{Cells}[$row][4]->{Val} eq "") {$serial=0} else {$serial=$sheet->{Cells}[$row][4]->{Val}}; # This syntax always returns 0 even when the match should return the value of $row,4