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

Inspecting and printing @array, @F and the raw-line all show that the final entry is a blank line. The split handles all lines containing content as intended, and these errors only occur when it reaches the end of any given input file - but skipping empty lines still does not appear to work oddly.

Replies are listed 'Best First'.
Re^5: Illegal division by zero error
by poj (Abbot) on Feb 01, 2016 at 18:02 UTC

    /^\s+$/ needs one or more to skip

    Try /^\s*$/

    poj
      Thank you. This seems to have solved it. I didn't realise that /^\s+$/ relied on their being 1 or more.
        OK, have a look at quantifiers in perlre
Re^5: Illegal division by zero error
by Laurent_R (Canon) on Feb 01, 2016 at 18:04 UTC
    Then you are probably not doing the right thing to skip "empty" lines. Or the line in question might not be really empty (there could be a new line character or some spaces that you can't see).

    How do you skip empty lines? Perhaps you should remove spaces before (unless your lines have necessary spaces), or detect that the line doesn't have any character other than spaces.

    We can't say for sure, not having seen your input, but it could be something like this:

    next unless /\S/;
    which will skip the line unless it contains any non-space character.