in reply to Re^2: Illegal division by zero error
in thread Illegal division by zero error

So you have ascertained that the error happens because you enter that block of code but $array[4] contains a value that Perl interprets as zero.

Maybe you don't want to enter that block if $array[4] contains a value that Perl interprets as zero? Maybe you want to prevent processing invalid lines that leave invalid values in @F?

You have not shown examples of valid and problematic lines, so we can only guess and trace the path of execution backwards from where the error happens. If you tell us what you want to avoid, or for what kind of lines the error happens, maybe we can better find a solution with you.

Maybe you want to skip processing empty lines?

Replies are listed 'Best First'.
Re^4: Illegal division by zero error
by TJCooper (Beadle) on Feb 01, 2016 at 16:51 UTC
    I was not originally aware that this could be caused by blank lines (because there are no blank lines at the end of the input files). I've tried skipping blank lines as suggested above, but this has not remedied the error. Currently, the error currently only occurs when the script attempts to process past the final line of the input. I can't figure out why it's attempting to do this in the first place.

      There are many ways that the relevant code block could be entered. Maybe you want to print out the line that is processed, together with the values stored in @array and the values stored in @F to determine what the line looks like instead of guessing that it must be an empty line?

        When using print OUT "@F\n", the final line is simply a blank line (unless it contains special characters I cannot see) - although no such line appears on the input. This is also true of @array and printing the non-split line.