<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I have a question?<b> </b>My instructor did not pass me on my script/library project because of "illegal division by zero on line 14 of obj13-lib.pl (my library) part of my script. <br>What am I doing wrong and can someone help me? <br><br>I would really appreciate help with this.<br><br>&nbsp;I thought I got this correct.<b><br></b><br>This is a description of my project goal, and below is my graded script.:<b><br><br></b>Write a script called <i>obj13-1.pl</i> and a library called
<i>obj13-lib.pl</i>.  The library should contain a function that takes
in an array of numbers (of arbitrary size).  The function will then
calculate the average of the numbers, the total of all of the numbers
added together, and a new array of numbers which is comprised of the other numbers
divided by 2.<br><b><br>Objective:</b><br>
See Project Page.<br><b>Here are the contents of the file you handed in:</b><br>
<font color="black"><pre>Script output:<br>-------------------------------<br>Illegal division by zero at obj13-lib.pl line 14.<br><br>-------------------------------<br>Script obj13.pl contents:<br>-------------------------------<br>#!/usr/bin/perl<br><br>require 'obj13-lib.pl';<br><br>while(<stdin>)<br><br>{<br><br>    chomp;<br>    last if ! /\d/;<br><br>    push(@userArray,$_);<br>}<br><br>($sum,$avg) = &amp;sumIt(@userArray);<br><br>print "Total:$sum\nAverage:$avg\n";<br><br>#_END_<br><br></stdin></pre></font>
<font size="+1"><b>Overall Comments:</b><br></font>
<font color="black"><b>Good!  What about the new array that is created using the original array elements, divided by 2?
<br><br></b>My library script</font><span style="font-family: monospace;"> </span><span style="font-weight: bold;">obj13-lib.pl</span> below<font color="black"><b>:<br><br>#!/usr/bin/perl <br></b></font><br>sub sumIt {<br><br> @functionArray = @_;<br><br> foreach $line(@functionArray){<br><br> $functionSum += $line;<br><br> $count++<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>return ($functionSum,$functionSum / $count);<br><br>}<br><br>1;<br><br><br>#_END_<br><br></td></tr></table><br>