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

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.

Replies are listed 'Best First'.
Re^5: Illegal division by zero error
by Corion (Patriarch) on Feb 01, 2016 at 16:56 UTC

    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.

        Why do you print out @F when you want to inspect the contents of $_?

        Maybe you want to add the following line in a strategic place of your script?

        print "Now processing [$_]\n";

        Consider also adding

        use Data::Dumper; print Dumper \@F; print Dumper \@array;

        ... after you've populated @F and @array.