in reply to Illegal division by zero error
Your script executes line 15 if index($F[4],','); returns -1, which means if the comma isn't found. There are two obvious situations where the comma would not be found: (1) The input data has at least ten fields but there is no comma in the tenth field, or (2) The input data doesn't have ten fields. The second situation can happen, as an example, if your script encounters an empty line. Essentially, you're not handling blank lines or lines that don't conform to expectations. Even in a really sanitary data set, a blank line will often occur at the end of the file. If every line of the input ends with a \n, then the last useful data line also has a newline at the end, leaving an empty line after it. Solve the problem by skipping empty lines. Right after your chomp, put a sanity check: next unless length $_;
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Illegal division by zero error
by TJCooper (Beadle) on Feb 01, 2016 at 16:46 UTC | |
by davido (Cardinal) on Feb 01, 2016 at 16:50 UTC | |
by TJCooper (Beadle) on Feb 01, 2016 at 17:12 UTC | |
by poj (Abbot) on Feb 01, 2016 at 18:02 UTC | |
by TJCooper (Beadle) on Feb 01, 2016 at 18:16 UTC | |
| |
by Laurent_R (Canon) on Feb 01, 2016 at 18:04 UTC |