I am taking an online ceu course in scripting with Unix. I have been stumped by 
this project. Can anyone out there help me out a bit. I created a script at the 
bottom and it does not quite work. What am I missing? 
I know I am missing some thing but this is my first time working with perl. I 
know it will take me a while to get good at it but so far its been fun.  I 
would appreciate the help if possible. 
Here is my project and below is my code.
 
Write a script called obj.pl and a library called obj-lib.pl. 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. It will then return a new list 
with all of that information.

The script file, obj.pl should get a list of numbers from the user (either via 
STDIN or a list of arguments) and call the library function.
 
Here is my script to solve the project. 
 
#!/usr/bin/perl

require 'lib.pl';

@userArray = <STDIN>;

$sum = sumIt(@userArray);

print $sum;

#_END_
 
And then for my library:

sub sumIt(){
   @functionArray = @_;
   foreach $line(@functionArray){
   $functionSum += $line;
   }
   return $functionSum;
}

1;



      

Reply via email to