Problem about the Perl

First of all,thanks for you attention to my question.

When I run the perl which is shown in the attactment to calculate the "246K Hap_finalFrames.xtd",my job failed,and pointed out that "Illegal division by zero at -e line 142." Who can help me to find out the prolem with the perl?

Thanks!